https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123556
Bug ID: 123556
Summary: xdp-tools fails tests for bpf (access beyond struct
(anon) at off 2 size 8)
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: sjames at gcc dot gnu.org
CC: dfaust at gcc dot gnu.org, jemarch at gcc dot gnu.org
Blocks: 121462
Target Milestone: ---
Target: bpf
Created attachment 63326
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63326&action=edit
xdp_flowtable.bpf.i.xz
```
$ bpf-unknown-none-gcc -I ../headers/ -I ../headers/linux -I ../lib/../headers
-I../lib/util -Wall -Wno-unused-value -Wno-pointer-sign
-Wno-compare-distinct-pointer-types -Wno-visibility -Werror
-fno-stack-protector -I ../headers/ -I ../headers/linux -I ../lib/../headers
-I../lib/util -Wno-unknown-pragmas -Wno-unused-variable
-Wno-maybe-uninitialized -I/usr/include -I ../headers/ -I ../headers/linux -I
../lib/../headers -I../lib/util -DBPF_DIR_MNT=\"/sys/fs/bpf\"
-DBPF_OBJECT_PATH=\"/usr/local/lib/bpf\" -DMAX_DISPATCHER_ACTIONS=10
-DTOOLS_VERSION=\""1.6.0"\" -DLIBBPF_VERSION=\"1.6.2\" -DRUNDIR=\"/run\"
-DHAVE_BPFTOOL -DHAVE_LIBBPF_PERF_BUFFER__CONSUME
-DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID -DHAVE_LIBBPF_BTF__TYPE_CNT
-DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
-DHAVE_LIBBPF_BPF_PROGRAM__INSN_CNT -DHAVE_LIBBPF_BPF_PROGRAM__TYPE
-DHAVE_LIBBPF_BPF_PROGRAM__FLAGS
-DHAVE_LIBBPF_BPF_PROGRAM__EXPECTED_ATTACH_TYPE -DHAVE_LIBBPF_BPF_MAP_CREATE
-DHAVE_LIBBPF_PERF_BUFFER__NEW_RAW -DHAVE_LIBBPF_BPF_XDP_ATTACH
-DHAVE_LIBBPF_BPF_MAP__SET_AUTOCREATE -DHAVE_LIBBPF_BPF_PROG_TEST_RUN_OPTS
-DHAVE_LIBBPF_BPF_XDP_QUERY -DHAVE_SECURE_GETENV -DDEBUG -DLIBBPF_DYNAMIC
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I -I -I -I../lib/util
-I/usr/include/bpf/uapi -I/usr/include -I -I -I -I../lib/util -I -I -I
-I../lib/util -I/usr/include/bpf/uapi -I/usr/include -I -I -I -I../lib/util -I
-I -I -I../lib/util -I ../headers/ -I ../headers/linux -I ../lib/../headers
-I../lib/util -Wno-unknown-pragmas -Wno-unused-variable
-Wno-maybe-uninitialized -I/usr/include -I ../headers/ -I ../headers/linux -I
../lib/../headers -I../lib/util -DBPF_DIR_MNT=\"/sys/fs/bpf\"
-DBPF_OBJECT_PATH=\"/usr/local/lib/bpf\" -DMAX_DISPATCHER_ACTIONS=10
-DTOOLS_VERSION=\""1.6.0"\" -DLIBBPF_VERSION=\"1.6.2\" -DRUNDIR=\"/run\"
-DHAVE_BPFTOOL -DHAVE_LIBBPF_PERF_BUFFER__CONSUME
-DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID -DHAVE_LIBBPF_BTF__TYPE_CNT
-DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
-DHAVE_LIBBPF_BPF_PROGRAM__INSN_CNT -DHAVE_LIBBPF_BPF_PROGRAM__TYPE
-DHAVE_LIBBPF_BPF_PROGRAM__FLAGS
-DHAVE_LIBBPF_BPF_PROGRAM__EXPECTED_ATTACH_TYPE -DHAVE_LIBBPF_BPF_MAP_CREATE
-DHAVE_LIBBPF_PERF_BUFFER__NEW_RAW -DHAVE_LIBBPF_BPF_XDP_ATTACH
-DHAVE_LIBBPF_BPF_MAP__SET_AUTOCREATE -DHAVE_LIBBPF_BPF_PROG_TEST_RUN_OPTS
-DHAVE_LIBBPF_BPF_XDP_QUERY -DHAVE_SECURE_GETENV -DDEBUG -DLIBBPF_DYNAMIC
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I -I -I -I../lib/util
-I/usr/include/bpf/uapi -I/usr/include -I -I -I -I../lib/util -I -I -I
-I../lib/util -I/usr/include/bpf/uapi -I/usr/include -I -I -I -I../lib/util -I
-I -I -I../lib/util -I ../headers/ -I ../headers/linux -I ../lib/../headers
-I../lib/util -O2 -c -g -o xdp_flowtable.bpf.o xdp_flowtable.bpf.c
```
test_flowtable:
```
[...]
75: (0f) r3 += r5 ;
R3=ptr_flow_offload_tuple_rhash(off=184) R5=184
76: (07) r1 += -120 ; R1=fp-120
77: (85) call bpf_probe_read_kernel#113 ; R0=scalar()
fp-120=mmmmmmmm
78: (55) if r0 != 0x0 goto pc+237 ; R0=0
79: (69) r2 = *(u16 *)(r7 +58) ;
R2=scalar(smin=smin32=0,smax=umax=smax32=umax32=0xffff,var_off=(0x0; 0xffff))
R7=ptr_flow_offload_tuple_rhash()
80: (57) r2 &= 28 ;
R2=scalar(smin=smin32=0,smax=umax=smax32=umax32=28,var_off=(0x0; 0x1c))
81: (55) if r2 != 0x4 goto pc+234 ; R2=4
82: (79) r9 = *(u64 *)(r7 +56)
access beyond struct (anon) at off 2 size 8
processed 82 insns (limit 1000000) max_states_per_insn 0 total_states
3 peak_states 3 mark_read 0
-- END PROG LOAD LOG --
libbpf: prog 'xdp_fwd_flow_full': failed to load: -EACCES
libbpf: failed to load object 'xdp_flowtable'
Failed to attach XDP program to iface xdptest-5aa5: Permission denied
libxdp: No XDP dispatcher found on ifindex 3
libxdp: No XDP dispatcher found on ifindex 5
Command './xdp-forward load -f flowtable xdptest-5aa5 xdptest-18c8'
exited with status 1
```
```
Using built-in specs.
COLLECT_GCC=bpf-unknown-none-gcc
COLLECT_LTO_WRAPPER=/usr/lib/bpf-toolchain/libexec/gcc/bpf-unknown-none/15/lto-wrapper
Target: bpf-unknown-none
Configured with:
/var/tmp/portage/sys-devel/bpf-toolchain-15.2.0_p2/work/gcc/configure
--build=x86_64-pc-linux-gnu --target=bpf-unknown-none --docdir=/.skip
--infodir=/.skip --mandir=/.skip MAKEINFO=: --prefix=/usr/lib/bpf-toolchain
--host=x86_64-pc-linux-gnu --disable-bootstrap --disable-cc1 --disable-cet
--disable-gcov --disable-gomp --disable-nls --disable-libcc1
--disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libvtv
--disable-shared --disable-werror --enable-languages=c
--with-gcc-major-version-only --with-system-zlib --without-isl --without-zstd
--disable-multilib CXX='x86_64-pc-linux-gnu-g++ -std=c++14'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)
```
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121462
[Bug 121462] [meta-bug] BPF verifier issues