]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix ldx in ld_abs rewrite for large offsets
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 9 Jul 2018 22:43:22 +0000 (00:43 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 10 Jul 2018 15:15:30 +0000 (08:15 -0700)
commit6d0b4e30af3ae6296c3d641531514b9417d40628
treeae2b186ce2f62280bbd74b91a72a9166f8c34d39
parent1ae45dd73c43475cfd54616b7d7981228ddafdae
bpf: fix ldx in ld_abs rewrite for large offsets

Mark reported that syzkaller triggered a KASAN detected slab-out-of-bounds
bug in ___bpf_prog_run() with a BPF_LD | BPF_ABS word load at offset 0x8001.
After further investigation it became clear that the issue was the
BPF_LDX_MEM() which takes offset as an argument whereas it cannot encode
larger than S16_MAX offsets into it. For this synthetical case we need to
move the full address into tmp register instead and do the LDX without
immediate value.

Fixes: 84d9b76c63c2 ("bpf: implement ld_abs/ld_ind in native bpf")
Reported-by: syzbot <syzkaller@googlegroups.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/filter.c