All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
@ 2020-12-24  1:12 Jiang Wang
  2020-12-28 18:37 ` Song Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jiang Wang @ 2020-12-24  1:12 UTC (permalink / raw)
  To: bpf; +Cc: cong.wang, kpsingh, Jiang Wang

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.

Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
---
 tools/testing/selftests/bpf/progs/bprm_opts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/bprm_opts.c b/tools/testing/selftests/bpf/progs/bprm_opts.c
index 5bfef2887e70..418d9c6d4952 100644
--- a/tools/testing/selftests/bpf/progs/bprm_opts.c
+++ b/tools/testing/selftests/bpf/progs/bprm_opts.c
@@ -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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-24  1:12 [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC Jiang Wang
@ 2020-12-28 18:37 ` Song Liu
  2020-12-29  5:14   ` John Fastabend
  2020-12-28 18:41 ` Song Liu
  2020-12-29 14:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 7+ messages in thread
From: Song Liu @ 2020-12-28 18:37 UTC (permalink / raw)
  To: Jiang Wang; +Cc: bpf, cong.wang, KP Singh

On Wed, Dec 23, 2020 at 5:14 PM Jiang Wang <jiang.wang@bytedance.com> wrote:
>
> 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.
>
> Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>

Thanks for the fix!

Acked-by: Song Liu <songliubraving@fb.com>

[...]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-24  1:12 [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC Jiang Wang
  2020-12-28 18:37 ` Song Liu
@ 2020-12-28 18:41 ` Song Liu
  2020-12-29 14:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: Song Liu @ 2020-12-28 18:41 UTC (permalink / raw)
  To: Jiang Wang; +Cc: bpf, cong.wang, KP Singh

On Wed, Dec 23, 2020 at 5:14 PM Jiang Wang <jiang.wang@bytedance.com> wrote:
>
> 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.
>
> Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>

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

> ---
>  tools/testing/selftests/bpf/progs/bprm_opts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/bprm_opts.c b/tools/testing/selftests/bpf/progs/bprm_opts.c
> index 5bfef2887e70..418d9c6d4952 100644
> --- a/tools/testing/selftests/bpf/progs/bprm_opts.c
> +++ b/tools/testing/selftests/bpf/progs/bprm_opts.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-28 18:37 ` Song Liu
@ 2020-12-29  5:14   ` John Fastabend
  2020-12-29 14:28     ` Daniel Borkmann
  0 siblings, 1 reply; 7+ messages in thread
From: John Fastabend @ 2020-12-29  5:14 UTC (permalink / raw)
  To: Song Liu, Jiang Wang; +Cc: bpf, cong.wang, KP Singh

Song Liu wrote:
> On Wed, Dec 23, 2020 at 5:14 PM Jiang Wang <jiang.wang@bytedance.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
> 
> Thanks for the fix!
> 
> Acked-by: Song Liu <songliubraving@fb.com>
> 
> [...]


LGTM

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-29  5:14   ` John Fastabend
@ 2020-12-29 14:28     ` Daniel Borkmann
  2020-12-29 18:39       ` [External] " Jiang Wang .
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Borkmann @ 2020-12-29 14:28 UTC (permalink / raw)
  To: John Fastabend, Song Liu, Jiang Wang; +Cc: bpf, cong.wang, KP Singh, andrii

On 12/29/20 6:14 AM, John Fastabend wrote:
> Song Liu wrote:
>> On Wed, Dec 23, 2020 at 5:14 PM Jiang Wang <jiang.wang@bytedance.com> wrote:
>>>
>>> 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.
>>>
>>> Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
>>
>> Thanks for the fix!
>>
>> Acked-by: Song Liu <songliubraving@fb.com>
>>
>> [...]
> 
> LGTM
> 
> Acked-by: John Fastabend <john.fastabend@gmail.com>

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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-24  1:12 [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC Jiang Wang
  2020-12-28 18:37 ` Song Liu
  2020-12-28 18:41 ` Song Liu
@ 2020-12-29 14:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-29 14:30 UTC (permalink / raw)
  To: Jiang Wang; +Cc: bpf, cong.wang, kpsingh

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Thu, 24 Dec 2020 01:12:42 +0000 you wrote:
> 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.
> 
> [...]

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [External] Re: [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC
  2020-12-29 14:28     ` Daniel Borkmann
@ 2020-12-29 18:39       ` Jiang Wang .
  0 siblings, 0 replies; 7+ messages in thread
From: Jiang Wang . @ 2020-12-29 18:39 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: John Fastabend, Song Liu, bpf, cong.wang, KP Singh, andrii

Got it. Thank you guys. I will fix the title next time.


On Tue, Dec 29, 2020 at 6:28 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 12/29/20 6:14 AM, John Fastabend wrote:
> > Song Liu wrote:
> >> On Wed, Dec 23, 2020 at 5:14 PM Jiang Wang <jiang.wang@bytedance.com> wrote:
> >>>
> >>> 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.
> >>>
> >>> Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
> >>
> >> Thanks for the fix!
> >>
> >> Acked-by: Song Liu <songliubraving@fb.com>
> >>
> >> [...]
> >
> > LGTM
> >
> > Acked-by: John Fastabend <john.fastabend@gmail.com>
>
> 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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-29 18:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-24  1:12 [PATCH] selftests/bpf: fix a compile error for BPF_F_BPRM_SECUREEXEC Jiang Wang
2020-12-28 18:37 ` Song Liu
2020-12-29  5:14   ` John Fastabend
2020-12-29 14:28     ` Daniel Borkmann
2020-12-29 18:39       ` [External] " Jiang Wang .
2020-12-28 18:41 ` Song Liu
2020-12-29 14:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.