[PATCH v2 bpf-next 1/6] bpf: Add path_chmod and path_chown to d_inode_locked_hooks
From: Anton Protopopov
Date: Fri Dec 04 2026 - 10:43:15 EST
The chmod_common() and chown_common() functions call the path_chmod
and path_chown hooks with the inode locked. Both hooks are sleepable
but not in d_inode_locked_hooks. A program can't call the xattr
setters there now because path->dentry is not a trusted pointer. But
the list names the hooks called with the inode locked, and the
verifier would pick the wrong setters if path->dentry became trusted.
Add the two hooks.
Signed-off-by: Anton Protopopov <a.s.protopopov@xxxxxxxxx>
---
fs/bpf_fs_kfuncs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index 35ccd98a4de6..a512d449b54d 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -571,6 +571,10 @@ BTF_ID(func, bpf_lsm_inode_rmdir)
BTF_ID(func, bpf_lsm_inode_setattr)
BTF_ID(func, bpf_lsm_inode_setxattr)
BTF_ID(func, bpf_lsm_inode_unlink)
+#ifdef CONFIG_SECURITY_PATH
+BTF_ID(func, bpf_lsm_path_chmod)
+BTF_ID(func, bpf_lsm_path_chown)
+#endif
BTF_SET_END(d_inode_locked_hooks)
bool bpf_lsm_has_d_inode_locked(const struct bpf_prog *prog)
--
2.43.0