* [PATCH net 0/2] Minor fix in bpf_convert_ctx_access
@ 2017-08-11 16:31 Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 1/2] net: fix compilation when busy poll is not enabled Daniel Borkmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Borkmann @ 2017-08-11 16:31 UTC (permalink / raw)
To: davem; +Cc: ast, netdev, Daniel Borkmann
First one was found while trying to compile the kernel
with !CONFIG_NET_RX_BUSY_POLL.
Thanks!
Daniel Borkmann (2):
net: fix compilation when busy poll is not enabled
bpf: fix two missing target_size settings in bpf_convert_ctx_access
include/net/busy_poll.h | 12 ++++++------
net/core/filter.c | 2 ++
2 files changed, 8 insertions(+), 6 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net 1/2] net: fix compilation when busy poll is not enabled
2017-08-11 16:31 [PATCH net 0/2] Minor fix in bpf_convert_ctx_access Daniel Borkmann
@ 2017-08-11 16:31 ` Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 2/2] bpf: fix two missing target_size settings in bpf_convert_ctx_access Daniel Borkmann
2017-08-11 21:59 ` [PATCH net 0/2] Minor fix " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2017-08-11 16:31 UTC (permalink / raw)
To: davem; +Cc: ast, netdev, Daniel Borkmann
MIN_NAPI_ID is used in various places outside of
CONFIG_NET_RX_BUSY_POLL wrapping, so when it's not set
we run into build errors such as:
net/core/dev.c: In function 'dev_get_by_napi_id':
net/core/dev.c:886:16: error: ‘MIN_NAPI_ID’ undeclared (first use in this function)
if (napi_id < MIN_NAPI_ID)
^~~~~~~~~~~
Thus, have MIN_NAPI_ID always defined to fix these errors.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
include/net/busy_poll.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index 8ffd434..71c72a9 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -29,18 +29,18 @@
#include <linux/sched/signal.h>
#include <net/ip.h>
-#ifdef CONFIG_NET_RX_BUSY_POLL
-
-struct napi_struct;
-extern unsigned int sysctl_net_busy_read __read_mostly;
-extern unsigned int sysctl_net_busy_poll __read_mostly;
-
/* 0 - Reserved to indicate value not set
* 1..NR_CPUS - Reserved for sender_cpu
* NR_CPUS+1..~0 - Region available for NAPI IDs
*/
#define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
+#ifdef CONFIG_NET_RX_BUSY_POLL
+
+struct napi_struct;
+extern unsigned int sysctl_net_busy_read __read_mostly;
+extern unsigned int sysctl_net_busy_poll __read_mostly;
+
static inline bool net_busy_loop_on(void)
{
return sysctl_net_busy_poll;
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] bpf: fix two missing target_size settings in bpf_convert_ctx_access
2017-08-11 16:31 [PATCH net 0/2] Minor fix in bpf_convert_ctx_access Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 1/2] net: fix compilation when busy poll is not enabled Daniel Borkmann
@ 2017-08-11 16:31 ` Daniel Borkmann
2017-08-11 21:59 ` [PATCH net 0/2] Minor fix " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2017-08-11 16:31 UTC (permalink / raw)
To: davem; +Cc: ast, netdev, Daniel Borkmann
When CONFIG_NET_SCHED or CONFIG_NET_RX_BUSY_POLL is /not/ set and
we try a narrow __sk_buff load of tc_index or napi_id, respectively,
then verifier rightfully complains that it's misconfigured, because
we need to set target_size in each of the two cases. The rewrite
for the ctx access is just a dummy op, but needs to pass, so fix
this up.
Fixes: f96da09473b5 ("bpf: simplify narrower ctx access")
Reported-by: Shubham Bansal <illusionist.neo@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
net/core/filter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index f44fc22..6280a60 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
bpf_target_off(struct sk_buff, tc_index, 2,
target_size));
#else
+ *target_size = 2;
if (type == BPF_WRITE)
*insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
else
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
*insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
#else
+ *target_size = 4;
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
#endif
break;
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 0/2] Minor fix in bpf_convert_ctx_access
2017-08-11 16:31 [PATCH net 0/2] Minor fix in bpf_convert_ctx_access Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 1/2] net: fix compilation when busy poll is not enabled Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 2/2] bpf: fix two missing target_size settings in bpf_convert_ctx_access Daniel Borkmann
@ 2017-08-11 21:59 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-11 21:59 UTC (permalink / raw)
To: daniel; +Cc: ast, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 11 Aug 2017 18:31:23 +0200
> First one was found while trying to compile the kernel
> with !CONFIG_NET_RX_BUSY_POLL.
Series applied, thanks Daniel.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-11 21:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 16:31 [PATCH net 0/2] Minor fix in bpf_convert_ctx_access Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 1/2] net: fix compilation when busy poll is not enabled Daniel Borkmann
2017-08-11 16:31 ` [PATCH net 2/2] bpf: fix two missing target_size settings in bpf_convert_ctx_access Daniel Borkmann
2017-08-11 21:59 ` [PATCH net 0/2] Minor fix " David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).