Re: [PATCH -next -v4 02/17] LSM: pass struct path to the inode_setsecctx hook

From: Al Viro

Date: Tue Nov 17 2026 - 13:44:22 EST


On Tue, Nov 17, 2026 at 11:05:27PM +0800, Cai Xinchen wrote:
> The inode_setsecctx hook and its security_inode_setsecctx() caller in
> fs/nfsd operate on a dentry even though both have a struct path
> available. Pass a const struct path so that the coming conversion of the
> xattr helpers can be reflected in the implementations; for now SELinux
> and Smack keep passing path->dentry and &nop_mnt_idmap to
> __vfs_setxattr_locked().
>
> Also document in lsm_hook_defs.h what a struct path argument may be used
> for: it can be passed to VFS helpers taking a struct path, but nothing is
> guaranteed about path->mnt.

No, with the side of Hell, No.

> + * Hooks that take a struct path argument: the VFS only sanctions passing
> + * the path to VFS helpers that take a struct path (e.g. notify_change());
> + * it makes no guarantees with regard to path->mnt, whose layout and
> + * implementation details are subject to change. Implementations must
> + * not rely on its properties.

NAKed-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

If that kind of stuff actually does get passed to any existing hooks, we need
to fix that ASAP. If not, consider that a blanket NAK on any patch series
that would introduce such.

We are not going there. At all. "Must not rely on its properties" ==
"must make sure that no existing functions with struct path * arguments
ever have such malformed instances passed to them". Which is not going
to be feasible to enforce. And yes, that very much includes any VFS helpers.