Re: [PATCH] statx: don't leak STATX_ATTR_CHANGE_MONOTONIC in stx_attributes_mask
From: Jeff Layton
Date: Tue Nov 03 2026 - 07:16:24 EST
On Mon, 2026-11-02 at 23:46 -0800, Christoph Hellwig wrote:
> On Thu, Oct 29, 2026 at 12:20:27PM -0400, Jeff Layton wrote:
> > STATX_ATTR_CHANGE_MONOTONIC is kernel-internal. cp_statx() strips it
> > from stx_attributes but copies attributes_mask verbatim, so it leaks to
> > userland on filesystems that advertise it (nfs, ceph), e.g.
> > stx_attributes_mask = 0x8000000000b03000 on NFS.
> >
> > Mask it out of stx_attributes_mask too.
>
>
> This actually seems like useful information, any reason it is not
> reported? We'd probably want to renumber if for that, though.
>
Because we don't report the change attribute itself. There's no reason
to report whether it's monotonic if userspace can't get to it in the
first place.
> > tmp.stx_blocks = stat->blocks;
> > - tmp.stx_attributes_mask = stat->attributes_mask;
> > + tmp.stx_attributes_mask = stat->attributes_mask & ~STATX_ATTR_CHANGE_MONOTONIC;
>
> But if we want to keep internal only flags, they should have a mask
> defined next to the attributes intead of open coding specific ones here.
>
> And please avoid the overly long line as well.
Alrighty, I'll post a v2.
--
Jeff Layton <jlayton@xxxxxxxxxx>