Re: [PATCH vfs-7.5.bpf v2 1/3] bpf: Add bpf_path_getattr()

From: Christian Brauner

Date: Fri Nov 06 2026 - 03:41:37 EST


On Mon, Nov 02, 2026 at 12:46:53PM +0200, Anastasios Papagiannis wrote:
> + ret = vfs_getattr_nosec(path, &stat, request_mask, query_flags);

Hm, do_statx() filters both masks before they hit the filesystem and we
should do the same here:

if (request_mask & STATX__RESERVED)
return -EINVAL;
if ((query_flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
return -EINVAL;
request_mask &= ~STATX_CHANGE_COOKIE;

STATX_CHANGE_COOKIE isn't innocous... It causes generic_fillattr() to
call inode_query_iversion() which sets I_VERSION_QUERIED and forces the
next change to bump i_version.

That's in-kernel only. A bpf program shouldn't be able to set it on
every inode it looks at.

> -/* Side-effecting kfuncs that stay exclusive to LSM programs. */
> +/* Kfuncs that stay exclusive to LSM programs. */
> BTF_SET_START(bpf_fs_kfunc_lsm_only_ids)
> +BTF_ID(func, bpf_path_getattr)

I don't think this belongs here. The set exists so binfmt_misc
handlers can't modify filesystem state. bpf_path_getattr() doesn't
modify anything and the binfmt_misc match and load programs are
sleepable. So they can use it on bprm->file->f_path just like
bpf_path_d_path() and bpf_get_file_xattr(). I'd drop this.

--