diff mbox series

[1/2,net-next] bpf: fix link error without CONFIG_NET

Message ID 20171102110558.2746221-1-arnd@arndb.de
State Accepted, archived
Delegated to: David Miller
Headers show
Series [1/2,net-next] bpf: fix link error without CONFIG_NET | expand

Commit Message

Arnd Bergmann Nov. 2, 2017, 11:05 a.m. UTC
I ran into this link error with the latest net-next plus linux-next
trees when networking is disabled:

kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'

It seems that the code was written to deal with varying contents of
the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
and xdp_analyzer_ops are defined in the core networking code, so adding
a check for CONFIG_NET seems appropriate here, and I've verified this with
many randconfig builds

Fixes: 4f9218aaf8a4 ("bpf: move knowledge about post-translation offsets out of verifier")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Since there hasn't been a linux-next release in two weeks, I'm not
entirely sure this is still needed, but from looking of the net-next
contents it seems it is. I did not check any other trees that might
have a fix already.
---
 kernel/bpf/verifier.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jakub Kicinski Nov. 2, 2017, 5:55 p.m. UTC | #1
On Thu,  2 Nov 2017 12:05:51 +0100, Arnd Bergmann wrote:
> I ran into this link error with the latest net-next plus linux-next
> trees when networking is disabled:
> 
> kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
> kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'
> 
> It seems that the code was written to deal with varying contents of
> the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
> and xdp_analyzer_ops are defined in the core networking code, so adding
> a check for CONFIG_NET seems appropriate here, and I've verified this with
> many randconfig builds
> 
> Fixes: 4f9218aaf8a4 ("bpf: move knowledge about post-translation offsets out of verifier")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks Arnd!  I was hoping to nuke this code before build bots catch up
to me, didn't work out :)
Alexei Starovoitov Nov. 2, 2017, 6:48 p.m. UTC | #2
On Thu, Nov 02, 2017 at 10:55:30AM -0700, Jakub Kicinski wrote:
> On Thu,  2 Nov 2017 12:05:51 +0100, Arnd Bergmann wrote:
> > I ran into this link error with the latest net-next plus linux-next
> > trees when networking is disabled:
> > 
> > kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
> > kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'
> > 
> > It seems that the code was written to deal with varying contents of
> > the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
> > and xdp_analyzer_ops are defined in the core networking code, so adding
> > a check for CONFIG_NET seems appropriate here, and I've verified this with
> > many randconfig builds
> > 
> > Fixes: 4f9218aaf8a4 ("bpf: move knowledge about post-translation offsets out of verifier")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Thanks Arnd!  I was hoping to nuke this code before build bots catch up
> to me, didn't work out :)

yeah. Jakub's patches may not make it in time for net-next closing.
so let's use this fix for now.

Acked-by: Alexei Starovoitov <ast@kernel.org>
Daniel Borkmann Nov. 2, 2017, 10:32 p.m. UTC | #3
On 11/02/2017 12:05 PM, Arnd Bergmann wrote:
> I ran into this link error with the latest net-next plus linux-next
> trees when networking is disabled:
>
> kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
> kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'
>
> It seems that the code was written to deal with varying contents of
> the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
> and xdp_analyzer_ops are defined in the core networking code, so adding
> a check for CONFIG_NET seems appropriate here, and I've verified this with
> many randconfig builds
>
> Fixes: 4f9218aaf8a4 ("bpf: move knowledge about post-translation offsets out of verifier")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
David Miller Nov. 3, 2017, 5:20 a.m. UTC | #4
From: Arnd Bergmann <arnd@arndb.de>
Date: Thu,  2 Nov 2017 12:05:51 +0100

> I ran into this link error with the latest net-next plus linux-next
> trees when networking is disabled:
> 
> kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
> kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'
> 
> It seems that the code was written to deal with varying contents of
> the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
> and xdp_analyzer_ops are defined in the core networking code, so adding
> a check for CONFIG_NET seems appropriate here, and I've verified this with
> many randconfig builds
> 
> Fixes: 4f9218aaf8a4 ("bpf: move knowledge about post-translation offsets out of verifier")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.
diff mbox series

Patch

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 2bb6d6aa7085..750aff880ecb 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4561,8 +4561,10 @@  int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
 }
 
 static const struct bpf_verifier_ops * const bpf_analyzer_ops[] = {
+#ifdef CONFIG_NET
 	[BPF_PROG_TYPE_XDP]		= &xdp_analyzer_ops,
 	[BPF_PROG_TYPE_SCHED_CLS]	= &tc_cls_act_analyzer_ops,
+#endif
 };
 
 int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,