Minor fix in bpf_convert_ctx_access
Subsystems (4)
Daniel Borkmann
maintainercover Minor fix in bpf_convert_ctx_access
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(-)
Signature · 1 line
1.9.3
Daniel Borkmann
maintainerPATCH 1/2 net: fix compilation when busy poll is not enabled
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.
--- include/net/busy_poll.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/net/busy_poll.h +6 -6
@@ -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;
Signature · 1 line
1.9.3
Daniel Borkmann
maintainerPATCH 2/2 bpf: fix two missing target_size settings in bpf_convert_ctx_access
In reply to Daniel BorkmannWhen 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.
--- net/core/filter.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/filter.c +2 -0
@@ -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 ;
Signature · 1 line
1.9.3
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Fri, 11 Aug 2017 18:31:23 +0200
Quoted 2 lines
First one was found while trying to compile the kernel with !CONFIG_NET_RX_BUSY_POLL.
Series applied, thanks Daniel.