1
0
Fork 0
alistair23-linux/tools
Thomas Graf 57a09bf0a4 bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers
A BPF program is required to check the return register of a
map_elem_lookup() call before accessing memory. The verifier keeps
track of this by converting the type of the result register from
PTR_TO_MAP_VALUE_OR_NULL to PTR_TO_MAP_VALUE after a conditional
jump ensures safety. This check is currently exclusively performed
for the result register 0.

In the event the compiler reorders instructions, BPF_MOV64_REG
instructions may be moved before the conditional jump which causes
them to keep their type PTR_TO_MAP_VALUE_OR_NULL to which the
verifier objects when the register is accessed:

0: (b7) r1 = 10
1: (7b) *(u64 *)(r10 -8) = r1
2: (bf) r2 = r10
3: (07) r2 += -8
4: (18) r1 = 0x59c00000
6: (85) call 1
7: (bf) r4 = r0
8: (15) if r0 == 0x0 goto pc+1
 R0=map_value(ks=8,vs=8) R4=map_value_or_null(ks=8,vs=8) R10=fp
9: (7a) *(u64 *)(r4 +0) = 0
R4 invalid mem access 'map_value_or_null'

This commit extends the verifier to keep track of all identical
PTR_TO_MAP_VALUE_OR_NULL registers after a map_elem_lookup() by
assigning them an ID and then marking them all when the conditional
jump is observed.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-19 11:09:28 -04:00
..
arch tools: Synchronize tools/arch/x86/include/asm/cpufeatures.h 2016-10-05 19:18:34 -03:00
build tools build: Add feature detection for g++ 2016-10-05 19:59:35 -03:00
cgroup
firewire
gpio tools/gpio: fix gpio-event-mon header comment 2016-08-08 09:50:22 +02:00
hv Drivers: hv: utils: Check VSS daemon is listening before a hot backup 2016-09-02 17:22:51 +02:00
iio Second set of iio new device support, features and cleanups for the 4.9 cycle. 2016-09-14 20:42:03 +02:00
include bpf: add initial suite for selftests 2016-10-18 11:35:55 -04:00
kvm/kvm_stat tools: kvm_stat: Add comments 2016-05-25 16:12:06 +02:00
laptop/freefall
lguest tools/lguest: Don't bork the terminal in case of wrong args 2016-09-08 08:05:24 +02:00
lib tools lib traceevent: Fix kbuffer_read_at_offset() 2016-10-05 11:36:22 -03:00
net tools: bpf_jit_disasm: check for klogctl failure 2016-05-08 23:32:59 -04:00
nfsd
objtool objtool: Add do_task_dead() to global noreturn list 2016-09-23 07:28:05 +02:00
perf perf top/report: Add tips about a list option 2016-10-05 19:51:53 -03:00
power ACPICA: Cleanup for all string-to-integer conversions 2016-09-10 02:37:59 +02:00
scripts tools build: Fix objtool build with ARCH=x86_64 2016-07-22 16:37:44 -03:00
spi Merge remote-tracking branches 'spi/topic/ti-qspi', 'spi/topic/tools', 'spi/topic/txx9' and 'spi/topic/xlp' into spi-next 2016-09-30 09:14:22 -07:00
testing bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers 2016-10-19 11:09:28 -04:00
thermal/tmon
time
usb usbip: adding names db to port operation 2016-05-03 14:32:07 -07:00
virtio tools/virtio: add dma stubs 2016-08-15 05:05:51 +03:00
vm tools/vm/page_owner: increase temporary buffer size 2016-07-26 16:19:19 -07:00
Makefile tools/gpio: add install section 2016-06-23 11:07:13 +02:00