selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
Subsystems (3)
PATCH 1/1 selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
When CONFIG_BPF_LSM is not configured, running bpf selftesting will show BPF_F_BPRM_SECUREEXEC undefined error for bprm_opts.c.
The problem is that bprm_opts.c includes vmliunx.h. The vmlinux.h is generated by "bpftool btf dump file ./vmlinux format c". On the other hand, BPF_F_BPRM_SECUREEXEC is defined in include/uapi/linux/bpf.h and used only in bpf_lsm.c. When CONFIG_BPF_LSM is not set, bpf_lsm will not be compiled, so vmlinux.h will not include definition of BPF_F_BPRM_SECUREEXEC.
Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from vmlinux.h to bpf.h.
--- tools/testing/selftests/bpf/progs/bprm_opts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/bprm_opts.c +1 -1
@@ -4,7 +4,7 @@* Copyright 2020 Google LLC. */ -#include "vmlinux.h" +#include <linux/bpf.h> #include <errno.h> #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h>
Signature · 1 line
2.11.0
Quoted 11 lines · Jiang Wang
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.
Quoted 4 lines
Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from
vmlinux.htobpf.h.Signed-off-by Jiang Wang <[email protected]>
Thanks for the fix!
[...]
John Fastabend
Acked-byQuoted 15 lines · Song Liu
Quoted 14 lines · Jiang Wang
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from
vmlinux.htobpf.h.
Quoted 7 lines
Quoted 1 line
Signed-off-by Jiang Wang <[email protected]>Thanks for the fix!
Acked-by Song Liu <[email protected]>[...]
LGTM
Daniel Borkmann
maintainerQuoted 20 lines · John Fastabend
Quoted 19 lines · Song Liu
Quoted 11 lines · Jiang Wang
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.Quoted 4 lines
Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from
vmlinux.htobpf.h.Signed-off-by Jiang Wang <[email protected]>Thanks for the fix!
Quoted 7 lines
Quoted 3 lines
Acked-by Song Liu <[email protected]>[...]
LGTM
Acked-by John Fastabend <[email protected]>
I think it's okay'ish as a workaround, but in case that selftest needs to be extended to the point where we need kernel internal structures from vmlinux.h again, then we need to come up with a different solution. Overall, I'd like to remind that BPF selftests need to be run with the full/needed config options set to not miss out on coverage on some of the BPF subsystems. Anyway, applied, thx!
Got it. Thank you guys. I will fix the title next time.
Quoted 35 lines · Daniel Borkmann
Quoted 20 lines · John Fastabend
Quoted 19 lines · Song Liu
Quoted 11 lines · Jiang Wang
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.Quoted 4 lines
Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from
vmlinux.htobpf.h.Signed-off-by Jiang Wang <[email protected]>Thanks for the fix!
Quoted 7 lines
Quoted 3 lines
Acked-by Song Liu <[email protected]>[...]
LGTM
Acked-by John Fastabend <[email protected]>I think it's okay'ish as a workaround, but in case that selftest needs to be extended to the point where we need kernel internal structures from
vmlinux.hagain, then we need to come up with a different solution. Overall, I'd like to remind that BPF selftests need to be run with the full/needed config options set to not miss out on coverage on some of the BPF subsystems. Anyway, applied, thx!
Song Liu
reviewerQuoted 11 lines · Jiang Wang
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.
Quoted 4 lines
Ideally, we want to compile bpf selftest regardless of the configuration setting, so change the include file from
vmlinux.htobpf.h.Signed-off-by Jiang Wang <[email protected]>
btw: for future patches, please prefix the subject as [PATCH bpf] or [PATCH bpf-next], so it is
clear which tree the patch applies to. In this case, this should be bpf tree.
Thanks,
Song
Quoted 20 lines
--- tools/testing/selftests/bpf/progs/bprm_opts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/progs/bprm_opts.c +1
-2@@ -4,7 +4,7 @@* Copyright 2020 Google LLC. */ -#include "vmlinux.h" +#include <linux/bpf.h> #include <errno.h> #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> --2.11.0
This patch was applied to bpf/bpf.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
Quoted 11 lines · On Thu, 24 Dec 2020 01:12:42 +0000 you wrote:
When
CONFIG_BPF_LSMis not configured, running bpf selftesting will showBPF_F_BPRM_SECUREEXECundefined error forbprm_opts.c.The problem is that
bprm_opts.cincludesvmliunx.h. Thevmlinux.his generated by "bpftool btf dump file ./vmlinux format c". On the other hand,BPF_F_BPRM_SECUREEXECis defined ininclude/uapi/linux/bpf.hand used only inbpf_lsm.c. WhenCONFIG_BPF_LSMis not set,bpf_lsmwill not be compiled, sovmlinux.hwill not include definition ofBPF_F_BPRM_SECUREEXEC.[...]
Here is the summary with links:
- selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
https://git.kernel.org/bpf/bpf/c/da4282c17d69
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html