bpf: guard BTF_ID_FLAGS(bpf_cgroup_read_xattr) with CONFIG_BPF_LSM
Eduard Zingerman
maintainerPATCH 1/1 bpf: guard BTF_ID_FLAGS(bpf_cgroup_read_xattr) with CONFIG_BPF_LSM
Function bpf_cgroup_read_xattr is defined in fs/bpf_fs_kfuncs.c, which is compiled only when CONFIG_BPF_LSM is set. Add CONFIG_BPF_LSM check to bpf_cgroup_read_xattr spec in common_btf_ids in kernel/bpf/helpers.c to avoid build failures for configs w/o CONFIG_BPF_LSM.
Build failure example:
BTF .tmp_vmlinux1.btf.o
btf_encoder__tag_kfunc: failed to find kfunc 'bpf_cgroup_read_xattr' in BTF
...
WARN: resolve_btfids: unresolved symbol bpf_cgroup_read_xattr make[2]: *** [scripts/Makefile.vmlinux:91: vmlinux.unstripped] Error 255
--- kernel/bpf/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/helpers.c +1 -1
@@ -3779,7 +3779,7 @@ BTF_ID_FLAGS(func, bpf_strspn);BTF_ID_FLAGS (func, bpf_strcspn);BTF_ID_FLAGS (func, bpf_strstr);BTF_ID_FLAGS (func, bpf_strnstr); -#ifdef CONFIG_CGROUPS +#if defined(CONFIG_BPF_LSM ) && defined(CONFIG_CGROUPS ) BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)#endif BTF_KFUNCS_END (common_btf_ids)
Signature · 1 line
2.47.1
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Fri, 27 Jun 2025 10:53:09 -0700 you wrote:
Function
bpf_cgroup_read_xattris defined infs/bpf_fs_kfuncs.c, which is compiled only whenCONFIG_BPF_LSMis set. AddCONFIG_BPF_LSMcheck tobpf_cgroup_read_xattrspec incommon_btf_idsinkernel/bpf/helpers.cto avoid build failures for configs w/oCONFIG_BPF_LSM.Build failure example:
[...]
Here is the summary with links:
- [bpf-next,v1] bpf: guard BTF_ID_FLAGS(bpf_cgroup_read_xattr) with CONFIG_BPF_LSM
https://git.kernel.org/bpf/bpf-next/c/a5a7b25d7535
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html