Re: [PATCH] statx: don't leak STATX_ATTR_CHANGE_MONOTONIC in stx_attributes_mask

From: Christoph Hellwig

Date: Tue Nov 03 2026 - 02:52:11 EST


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.

> 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.