Commit 2ed46ce4 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

bpf: fix two missing target_size settings in bpf_convert_ctx_access

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: f96da094 ("bpf: simplify narrower ctx access")
Reported-by: default avatarShubham Bansal <illusionist.neo@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e4dde412
...@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, ...@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
bpf_target_off(struct sk_buff, tc_index, 2, bpf_target_off(struct sk_buff, tc_index, 2,
target_size)); target_size));
#else #else
*target_size = 2;
if (type == BPF_WRITE) if (type == BPF_WRITE)
*insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg); *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
else else
...@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type, ...@@ -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_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0); *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
#else #else
*target_size = 4;
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0); *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
#endif #endif
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment