Skip to content

Commit 96a94cc

Browse files
jmberg-inteldavem330
authored andcommitted
bpf: reference may_access_skb() from __bpf_prog_run()
It took me quite some time to figure out how this was linked, so in order to save the next person the effort of finding it add a comment in __bpf_prog_run() that indicates what exactly determines that a program can access the ctx == skb. Signed-off-by: Johannes Berg <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 17c3060 commit 96a94cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/bpf/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,12 +1162,12 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)
11621162
LD_ABS_W: /* BPF_R0 = ntohl(*(u32 *) (skb->data + imm32)) */
11631163
off = IMM;
11641164
load_word:
1165-
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are
1166-
* only appearing in the programs where ctx ==
1167-
* skb. All programs keep 'ctx' in regs[BPF_REG_CTX]
1168-
* == BPF_R6, bpf_convert_filter() saves it in BPF_R6,
1169-
* internal BPF verifier will check that BPF_R6 ==
1170-
* ctx.
1165+
/* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are only
1166+
* appearing in the programs where ctx == skb
1167+
* (see may_access_skb() in the verifier). All programs
1168+
* keep 'ctx' in regs[BPF_REG_CTX] == BPF_R6,
1169+
* bpf_convert_filter() saves it in BPF_R6, internal BPF
1170+
* verifier will check that BPF_R6 == ctx.
11711171
*
11721172
* BPF_ABS and BPF_IND are wrappers of function calls,
11731173
* so they scratch BPF_R1-BPF_R5 registers, preserve

0 commit comments

Comments
 (0)