Re: [PATCH v5 08/12] fs,overlayfs: add fileattr masks support on get

From: Amir Goldstein

Date: Sat Dec 05 2026 - 16:43:13 EST


On Sat, Dec 5, 2026 at 3:25 PM koraynilay <koray.fra@xxxxxxxxx> wrote:
>
> Add transitional get_only_masks selector in file_kattr for filesystems
> that want to advertise their read-only mask on GET but don't want to
> receive masked requests on SET.
>
> Use it in ovl_fileattr_get() to ask the VFS for unmasked SET if the
> underlying filesystem returns masks on GET, otherwise ovl_set_protattr()
> treats fa->flags as the full set of flags and clears IMMUTABLE/APPEND.
>
> Signed-off-by: koraynilay <koray.fra@xxxxxxxxx>
> ---
>
> Amir, is this commit message correct?
> This is what I understood, but I'm not 100% sure.
>
> I wanted to mention the actual bugs fixed, but since I haven't
> understood them that much I didn't want to just leave the robot's
> explanation in the commit message :D
>

It's ok that you framed it as an API patch which ovl uses, but in fact
there are no other users in-tree at the moment, only a future one,
so we can frame this the other way around, as a property added to
solve an ovl problem:

ovl: do not accept masked fileattr set requests

ovl_fileattr_get() reports the real inode's masks as its own.
When the upper filesystem supports masks, the VFS would send
overlayfs masked set requests, where fa->flags only contains the
flags selected by fsx_xflags_rw_mask.

ovl_set_protattr() treats fa->flags as the full set of flags,
so for example chattr +d on an append-only file would clear the
append-only flag. The VFS CAP_LINUX_IMMUTABLE check does
not catch this because the request does not select APPEND.

Add a transitional get_only_masks selector, and set it in
ovl_fileattr_get(), so the VFS converts masked set requests to
unmasked set requests before calling ovl_fileattr_set().

Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>

Thanks,
Amir.