summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrey Ignatov <rdna@fb.com>2021-09-13 18:35:27 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-22 11:47:58 +0200
commitcaee4103f09e3dcce2ec0d0faf6ff245a6cffbad (patch)
tree94726935381cb623aa2aecfba95a51bfb494c805 /include
parent79aba0ac3df1a604e843780b17c37646e175b4f8 (diff)
downloadlinux-stable-caee4103f09e3dcce2ec0d0faf6ff245a6cffbad.tar.gz
linux-stable-caee4103f09e3dcce2ec0d0faf6ff245a6cffbad.tar.bz2
linux-stable-caee4103f09e3dcce2ec0d0faf6ff245a6cffbad.zip
bpf: Support variable offset stack access from helpers
commit 2011fccfb61bbd1d7c8864b2b3ed7012342e9ba3 upstream. Currently there is a difference in how verifier checks memory access for helper arguments for PTR_TO_MAP_VALUE and PTR_TO_STACK with regard to variable part of offset. check_map_access, that is used for PTR_TO_MAP_VALUE, can handle variable offsets just fine, so that BPF program can call a helper like this: some_helper(map_value_ptr + off, size); , where offset is unknown at load time, but is checked by program to be in a safe rage (off >= 0 && off + size < map_value_size). But it's not the case for check_stack_boundary, that is used for PTR_TO_STACK, and same code with pointer to stack is rejected by verifier: some_helper(stack_value_ptr + off, size); For example: 0: (7a) *(u64 *)(r10 -16) = 0 1: (7a) *(u64 *)(r10 -8) = 0 2: (61) r2 = *(u32 *)(r1 +0) 3: (57) r2 &= 4 4: (17) r2 -= 16 5: (0f) r2 += r10 6: (18) r1 = 0xffff888111343a80 8: (85) call bpf_map_lookup_elem#1 invalid variable stack read R2 var_off=(0xfffffffffffffff0; 0x4) Add support for variable offset access to check_stack_boundary so that if offset is checked by program to be in a safe range it's accepted by verifier. Signed-off-by: Andrey Ignatov <rdna@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> [OP: replace reg_state(env, regno) helper with "cur_regs(env) + regno"] Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions