Skip to content

Commit 2ed46ce

Browse files
borkmanndavem330
authored andcommitted
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: f96da09 ("bpf: simplify narrower ctx access") Reported-by: Shubham Bansal <illusionist.neo@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e4dde41 commit 2ed46ce

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/core/filter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
35053505
bpf_target_off(struct sk_buff, tc_index, 2,
35063506
target_size));
35073507
#else
3508+
*target_size = 2;
35083509
if (type == BPF_WRITE)
35093510
*insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
35103511
else
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
35203521
*insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
35213522
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
35223523
#else
3524+
*target_size = 4;
35233525
*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
35243526
#endif
35253527
break;

0 commit comments

Comments
 (0)