linux-stable/tools
Michal Schmidt c3ae972a22 selftests/bpf: Fix pointer arithmetic in test_xdp_do_redirect
[ Upstream commit e549b39a0a ]

Cast operation has a higher precedence than addition. The code here
wants to zero the 2nd half of the 64-bit metadata, but due to a pointer
arithmetic mistake, it writes the zero at offset 16 instead.

Just adding parentheses around "data + 4" would fix this, but I think
this will be slightly better readable with array syntax.

I was unable to test this with tools/testing/selftests/bpf/vmtest.sh,
because my glibc is newer than glibc in the provided VM image.
So I just checked the difference in the compiled code.
objdump -S tools/testing/selftests/bpf/xdp_do_redirect.test.o:
  -	*((__u32 *)data) = 0x42; /* metadata test value */
  +	((__u32 *)data)[0] = 0x42; /* metadata test value */
        be7:	48 8d 85 30 fc ff ff 	lea    -0x3d0(%rbp),%rax
        bee:	c7 00 42 00 00 00    	movl   $0x42,(%rax)
  -	*((__u32 *)data + 4) = 0;
  +	((__u32 *)data)[1] = 0;
        bf4:	48 8d 85 30 fc ff ff 	lea    -0x3d0(%rbp),%rax
  -     bfb:	48 83 c0 10          	add    $0x10,%rax
  +     bfb:	48 83 c0 04          	add    $0x4,%rax
        bff:	c7 00 00 00 00 00    	movl   $0x0,(%rax)

Fixes: 5640b6d894 ("selftests/bpf: fix "metadata marker" getting overwritten by the netstack")
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20240506145023.214248-1-mschmidt@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-12 11:11:49 +02:00
..
accounting
arch x86/CPU/AMD: Add X86_FEATURE_ZEN1 2024-04-10 16:35:47 +02:00
bootconfig
bpf bpftool: Mount bpffs on provided dir instead of parent dir 2024-06-12 11:11:38 +02:00
build perf cs-etm: Bump minimum OpenCSD version to ensure a bugfix is present 2024-02-05 20:14:31 +00:00
certs
cgroup iocost_monitor: improve it by adding iocg wait_ms 2023-08-08 15:43:03 -06:00
counter
crypto/ccp crypto: ccp - Fix some unfused tests 2023-11-20 11:59:18 +01:00
debugging
edid
firewire
firmware
gpio
hv hv/hv_kvp_daemon: Some small fixes for handling NM keyfiles 2023-12-03 07:33:02 +01:00
iio tools: iio: replace seekdir() in iio_generic_buffer 2024-04-13 13:07:38 +02:00
include bpf: Pack struct bpf_fib_lookup 2024-06-12 11:11:38 +02:00
kvm/kvm_stat
laptop
leds
lib libbpf: Fix error message in attach_kprobe_multi 2024-06-12 11:11:48 +02:00
memory-model
mm tools/mm: fix undefined reference to pthread_once 2023-09-05 10:13:45 -07:00
net/ynl tools: ynl: don't ignore errors in NLMSG_DONE messages 2024-05-02 16:32:36 +02:00
objtool objtool: Fix UNWIND_HINT_{SAVE,RESTORE} across basic blocks 2024-03-26 18:19:35 -04:00
pci
pcmcia
perf perf lock contention: Add a missing NULL check 2024-04-27 17:11:34 +02:00
power tools/power/turbostat: Fix uncore frequency file string 2024-05-17 12:02:16 +02:00
rcu
scripts
spi
testing selftests/bpf: Fix pointer arithmetic in test_xdp_do_redirect 2024-06-12 11:11:49 +02:00
thermal
time
tracing tools/latency-collector: Fix -Wformat-security compile warns 2024-06-12 11:11:19 +02:00
usb
verification tools/rv: Fix Makefile compiler options for clang 2024-02-23 09:25:14 +01:00
virtio tools/virtio: Add dma sync api for virtio test 2023-10-16 05:32:23 -04:00
wmi
workqueue workqueue: Implement non-strict affinity scope for unbound workqueues 2023-08-07 15:57:25 -10:00
Makefile