Skip to content

Commit 6e07a63

Browse files
borkmannAlexei Starovoitov
authored andcommitted
bpf: Switch BPF probe insns to bpf_probe_read_kernel
Commit 2a02759 ("bpf: Add support for BTF pointers to interpreter") explicitly states that the pointer to BTF object is a pointer to a kernel object or NULL. Therefore we should also switch to using the strict kernel probe helper which is restricted to kernel addresses only when architectures have non-overlapping address spaces. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/d2b90827837685424a4b8008dfe0460558abfada.1572649915.git.daniel@iogearbox.net
1 parent 6ae08ae commit 6e07a63

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/bpf/core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,12 @@ bool bpf_opcode_in_insntable(u8 code)
13061306
}
13071307

13081308
#ifndef CONFIG_BPF_JIT_ALWAYS_ON
1309-
u64 __weak bpf_probe_read(void * dst, u32 size, const void * unsafe_ptr)
1309+
u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr)
13101310
{
13111311
memset(dst, 0, size);
13121312
return -EFAULT;
13131313
}
1314+
13141315
/**
13151316
* __bpf_prog_run - run eBPF program on a given context
13161317
* @regs: is the array of MAX_BPF_EXT_REG eBPF pseudo-registers
@@ -1566,9 +1567,9 @@ static u64 __no_fgcse ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, u6
15661567
LDST(W, u32)
15671568
LDST(DW, u64)
15681569
#undef LDST
1569-
#define LDX_PROBE(SIZEOP, SIZE) \
1570-
LDX_PROBE_MEM_##SIZEOP: \
1571-
bpf_probe_read(&DST, SIZE, (const void *)(long) SRC); \
1570+
#define LDX_PROBE(SIZEOP, SIZE) \
1571+
LDX_PROBE_MEM_##SIZEOP: \
1572+
bpf_probe_read_kernel(&DST, SIZE, (const void *)(long) SRC); \
15721573
CONT;
15731574
LDX_PROBE(B, 1)
15741575
LDX_PROBE(H, 2)

0 commit comments

Comments
 (0)