Skip to content

Commit a5a7b25

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
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 Fixes: 535b070 ("bpf: Introduce bpf_cgroup_read_xattr to read xattr of cgroup's node") Reported-by: Jake Hillion <[email protected]> Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 5272b51 commit a5a7b25

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3779,7 +3779,7 @@ BTF_ID_FLAGS(func, bpf_strspn);
37793779
BTF_ID_FLAGS(func, bpf_strcspn);
37803780
BTF_ID_FLAGS(func, bpf_strstr);
37813781
BTF_ID_FLAGS(func, bpf_strnstr);
3782-
#ifdef CONFIG_CGROUPS
3782+
#if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS)
37833783
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
37843784
#endif
37853785
BTF_KFUNCS_END(common_btf_ids)

0 commit comments

Comments
 (0)