linux-stable/tools
Yonghong Song 0d7410ea6e tools/bpf: check precise {func, line, jited_line}_info_rec_size in test_btf
Current btf func_info, line_info and jited_line are designed to be
extensible. The record sizes for {func,line}_info are passed to kernel,
and the record sizes for {func,line,jited_line}_info are returned to
userspace during bpf_prog_info query.

In bpf selftests test_btf.c, when testing whether kernel returns
a legitimate {func,line, jited_line)_info rec_size, the test only
compares to the minimum allowed size. If the returned rec_size is smaller
than the minimum allowed size, it is considered incorrect.
The minimum allowed size for these three info sizes are equal to
current value of sizeof(struct bpf_func_info), sizeof(struct bpf_line_info)
and sizeof(__u64).

The original thinking was that in the future when rec_size is increased
in kernel, the same test should run correctly. But this sacrificed
the precision of testing under the very kernel the test is shipped with,
and bpf selftest is typically run with the same repo kernel.

So this patch changed the testing of rec_size such that the
kernel returned value should be equal to the size defined by
tools uapi header bpf.h which syncs with kernel uapi header.

Martin discovered a bug in one of rec_size comparisons.
Instead of comparing to minimum func_info rec_size 8, it compares to 4.
This patch fixed that issue as well.

Fixes: 999d82cbc0 ("tools/bpf: enhance test_btf file testing to test func info")
Fixes: 05687352c6 ("bpf: Refactor and bug fix in test_func_type in test_btf.c")
Fixes: 4d6304c763 ("bpf: Add unit tests for bpf_line_info")
Suggested-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-12-18 14:46:32 +01:00
..
accounting delayacct: track delays from thrashing cache pages 2018-10-26 16:26:32 -07:00
arch tools arch x86: Update tools's copy of cpufeatures.h 2018-11-19 12:27:07 -08:00
bpf tools: bpftool: support pretty print with kind_flag set 2018-12-18 01:12:00 +01:00
build tools build feature: Check if get_current_dir_name() is available 2018-11-19 12:12:17 -08:00
cgroup
crypto crypto: tools - Add cryptostat userspace 2018-09-28 12:46:26 +08:00
firewire
gpio
hv tools: hv: fcopy: set 'error' in case an unknown operation was requested 2018-09-30 08:49:55 -07:00
iio
include tools/bpf: sync btf.h header from kernel to tools 2018-12-18 01:11:59 +01:00
kvm/kvm_stat tools/kvm_stat: cut down decimal places in update interval dialog 2018-10-01 15:40:59 +02:00
laptop
leds
lib bpf: libbpf: fix memleak by freeing line_info 2018-12-18 01:16:23 +01:00
memory-model tools/memory-model: Add more LKMM limitations 2018-10-02 10:28:04 +02:00
nfsd
objtool objtool: Fix segfault in .cold detection with -ffunction-sections 2018-11-20 18:59:00 +01:00
pci tools: PCI: Change pcitest compiling process 2018-10-03 11:19:52 +01:00
pcmcia
perf perf tools beauty ioctl: Support new ISO7816 commands 2018-11-19 12:38:50 -08:00
power tools cpupower: Override CFLAGS assignments 2018-11-06 08:54:16 -07:00
scripts
spi spi: spidev_test: Improve decoded text part of hex dump 2018-09-04 17:00:37 +01:00
testing tools/bpf: check precise {func, line, jited_line}_info_rec_size in test_btf 2018-12-18 14:46:32 +01:00
thermal/tmon
time
usb usbip: tools: fix atoi() on non-null terminated string 2018-10-18 19:44:39 +02:00
virtio
vm tools/vm/page-types.c: fix "defined but not used" warning 2018-09-04 16:45:02 -07:00
wmi
Makefile tools: PCI: Change pcitest compiling process 2018-10-03 11:19:52 +01:00