linux-stable/tools
Yonghong Song 12e6196fb1 selftests/bpf: Test bpf_iter buffer access with negative offset
Commit afbf21dce6 ("bpf: Support readonly/readwrite buffers
in verifier") added readonly/readwrite buffer support which
is currently used by bpf_iter tracing programs. It has
a bug with incorrect parameter ordering which later fixed
by Commit f6dfbe31e8 ("bpf: Fix swapped arguments in calls
to check_buffer_access").

This patch added a test case with a negative offset access
which will trigger the error path.

Without Commit f6dfbe31e8, running the test case in the patch,
the error message looks like:
   R1_w=rdwr_buf(id=0,off=0,imm=0) R10=fp0
  ; value_sum += *(__u32 *)(value - 4);
  2: (61) r1 = *(u32 *)(r1 -4)
  R1 invalid (null) buffer access: off=-4, size=4

With the above commit, the error message looks like:
   R1_w=rdwr_buf(id=0,off=0,imm=0) R10=fp0
  ; value_sum += *(__u32 *)(value - 4);
  2: (61) r1 = *(u32 *)(r1 -4)
  R1 invalid rdwr buffer access: off=-4, size=4

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200728221801.1090406-1-yhs@fb.com
2020-07-31 00:43:49 +02:00
..
accounting
arch tools arch kvm: Sync kvm headers with the kernel sources 2020-07-17 09:39:16 -03:00
bootconfig tools/bootconfig: Add testcase for show-command and quotes test 2020-06-16 21:21:03 -04:00
bpf tools, bpftool: Add LSM type to array of prog names 2020-07-27 22:40:54 +02:00
build tools/bpftool: Generalize BPF skeleton support and generate vmlinux.h 2020-06-22 17:01:48 -07:00
cgroup Merge branch 'block-5.7' into for-5.8/block 2020-05-09 16:13:58 -06:00
debugging
edid
firewire
firmware
gpio tools: gpio: add bias flags to lsgpio 2020-05-05 18:27:09 +02:00
hv
iio
include bpf: Fix bpf_ringbuf_output() signature to return long 2020-07-28 12:20:44 +02:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Add support for BPF XDP link 2020-07-25 20:37:02 -07:00
memory-model
nfsd
objtool Peter Zijlstra says: 2020-06-28 10:16:15 -07:00
pci
pcmcia
perf Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-07-25 17:49:04 -07:00
power Merge branch 'acpica' 2020-06-10 17:27:28 +02:00
scripts
spi spi: tools: Make default_tx/rx and input_tx static 2020-06-11 16:27:24 +01:00
testing selftests/bpf: Test bpf_iter buffer access with negative offset 2020-07-31 00:43:49 +02:00
thermal/tmon
time
usb
virtio tools/virtio: Use tools/include/list.h instead of stubs 2020-06-22 12:34:22 -04:00
vm tools/vm/page_owner_sort.c: filter out unneeded line 2020-06-03 20:09:49 -07:00
wmi
Makefile bpf: Compile resolve_btfids tool at kernel compilation start 2020-07-13 10:42:02 -07:00