[PATCH -next -v4 05/17] LSM: pass struct path and struct file to the inode xattr hooks

sashiko-bot at kernel.org sashiko-bot at kernel.org
Tue Nov 17 15:03:19 UTC 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bpf: missing BTF_TYPE_SAFE_TRUSTED for struct path breaks
  xattr kfuncs
--

commit 8e13dee6fc4fbca67536485e5988ae543a847e9e
Author: Cai Xinchen <caixinchen1 at huawei.com>

LSM: pass struct path and struct file to the inode xattr hooks

This commit converts the inode_setxattr, inode_getxattr, inode_listxattr,
and inode_removexattr LSM hooks and VFS xattr helpers to take a const
struct path * instead of a struct dentry *, and threads an optional struct
file * through them.

> diff --git a/tools/testing/selftests/bpf/progs/test_get_xattr.c b/tools/testing/selftests/bpf/progs/test_get_xattr.c
> index 54305f4c9f2dd..97361ff10e9f1 100644
> --- a/tools/testing/selftests/bpf/progs/test_get_xattr.c
> +++ b/tools/testing/selftests/bpf/progs/test_get_xattr.c
> @@ -56,7 +56,8 @@ int BPF_PROG(test_file_open, struct file *f)
>  }
>  
>  SEC("lsm.s/inode_getxattr")
> -int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
> +int BPF_PROG(test_inode_getxattr, const struct path *path, char *name,
> +	     struct file *file)
>  {
>  	struct bpf_dynptr value_ptr;
>  	__u32 pid;
> @@ -69,7 +70,7 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
>  	bpf_dynptr_from_mem(value2, sizeof(value2), 0, &value_ptr);
>  
>  	for (i = 0; i < ARRAY_SIZE(xattr_names); i++) {
> -		ret = bpf_get_dentry_xattr(dentry, xattr_names[i], &value_ptr);
> +		ret = bpf_get_dentry_xattr(path->dentry, xattr_names[i], &value_ptr);
>  		if (ret == sizeof(expected_value))
>  			break;
>  	}

[Severity: Medium]
Does the verifier reject passing path->dentry to bpf_get_dentry_xattr()
here and in test_set_remove_xattr.c?

Because struct path is not listed in BTF_TYPE_SAFE_TRUSTED in
type_is_trusted() at this commit, check_ptr_to_btf_access() drops
PTR_TRUSTED when dereferencing path->dentry, causing the xattr kfuncs to
reject the argument and breaking these BPF selftests across bisection.
A later patch in the series, commit "LSM: rename inode_setattr to
path_setattr and pass struct path and file", adds
BTF_TYPE_SAFE_TRUSTED(struct path); moving that verifier change to or
before this patch would keep these hooks and selftests working here.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117150542.1169451-1-caixinchen1@huawei.com?part=5



More information about the Linux-security-module-archive mailing list