summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-06-12 20:33:16 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-06-12 20:33:16 -0700
commit2ae53824b4462a13c2c773c57b2d2180a11d7fea (patch)
treee7bca3199eab2954238753d23aa47ab02efd07f5 /include/linux
parent746145bd7aaa3db2d77ef26aa8f3ebe1ca83cef6 (diff)
parentcec8423776176eb73429443ecb859789af9602e5 (diff)
Merge branch 'bpf-fix-setting-retval-to-eperm-for-cgroup-hooks-not-returning-errno'
Xu Kuohai says: ==================== bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno This series fixes the issue reported by sashiko in [1]. The issue is that, when a cgroup BPF program exits with 0, bpf_prog_run_array_cg() sets the hook return value to -EPERM if it is not a valid errno. This is correct for errno-based hooks, which return 0 on success and negative errno on failure, but wrong for void and boolean LSM hooks. Boolean LSM hooks should only return true or false, and void LSM hooks have no return value at all. Fix it by skipping setting -EPERM for hooks not returning errno. [1] https://lore.kernel.org/bpf/20260605144232.95A141F00893@smtp.kernel.org/ ==================== Link: https://patch.msgid.link/20260610201724.733943-1-xukuohai@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bpf_lsm.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h
index 643809cc78c3..143775a27a2a 100644
--- a/include/linux/bpf_lsm.h
+++ b/include/linux/bpf_lsm.h
@@ -52,6 +52,7 @@ int bpf_set_dentry_xattr_locked(struct dentry *dentry, const char *name__str,
const struct bpf_dynptr *value_p, int flags);
int bpf_remove_dentry_xattr_locked(struct dentry *dentry, const char *name__str);
bool bpf_lsm_has_d_inode_locked(const struct bpf_prog *prog);
+bool bpf_lsm_hook_returns_errno(u32 btf_id);
#else /* !CONFIG_BPF_LSM */
@@ -104,6 +105,11 @@ static inline bool bpf_lsm_has_d_inode_locked(const struct bpf_prog *prog)
{
return false;
}
+
+static inline bool bpf_lsm_hook_returns_errno(u32 btf_id)
+{
+ return true;
+}
#endif /* CONFIG_BPF_LSM */
#endif /* _LINUX_BPF_LSM_H */