NIC card driver does not set `xdp->frame_sz` properly in `bpf_xdp_adjust_tail`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- c, linux
- Domain
- networking
Research direction
Start with the bpf_xdp_adjust_tail check in net/core/filter.c and trace which NIC driver supplies the xdp_buff. Reproduce the failure with the described XDP program and inspect whether the driver updates xdp->frame_sz. Done means shrinking the frame no longer returns -EINVAL on the Raspberry Pi interface and the relevant behavior is covered by a regression test.
Written by the indexing model from the issue text.
Description
Describe the bug
Calling bpf_xdp_adjust_tail in XDP always fails with -EINVAL, even when shrinking the frame, because xdp->frame_sz > PAGE_SIZE returns false since xdp->frame_sz is over 30000 but PAGE_SIZE is 4096.
Steps to reproduce the behaviour
- Write a XDP program to call
bpf_xdp_adjust_tailin it, log the return value - Modify the kernel to
printkinbpf_xdp_adjust_tailto track which check fails - Compile the XDP program to eBPF executable and load it to a network interface
- Send some network traffic on the interface
cat /sys/kernel/debug/tracing/trace_pipeto get log from XDP program, which tellsbpf_xdp_adjust_tailfailed with-22=-EINVALdmesgto get log from kernel, which tellsxdp->frame_sz > PAGE_SIZEreturns false and causes the failure
Device (s)
Raspberry Pi 3 Mod. B+
System
- Which OS and version (
cat /etc/rpi-issue)?
Raspberry Pi OS (64-bit)
Raspberry Pi reference 2022-01-28
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, fbe448ccdc995d295d24c7596e5f0ef62cc2488f, stage2
- Which firmware version (
vcgencmd version)?
Jan 20 2022 13:58:22
Copyright (c) 2012 Broadcom
version bd88f66f8952d34e4e0613a85c7a6d3da49e13e2 (clean) (release) (start)
- Which kernel version (
uname -a)?
Self built on recent latest commit
Linux pi 5.15.28-v8+ #6 SMP PREEMPT Thu Mar 17 18:20:21 CST 2022 aarch64 GNU/Linux
Logs
No response
Additional context
According to the description from the author:
The idea is to catch drivers that forgot to update xdp_buff->frame_sz,
by doing some sanity checks on this uninit value. If I correctly
updated all XDP drivers in this patchset, then these checks should be
unnecessary, but will this be valuable for driver developers converting
new drivers to XDP to have these WARN checks?
So it should be the problem of the NIC card driver
I am not sure whether XDP is considered supported in Raspberry Pi, but since the feature is enabled:
modprobe configs
zgrep -E "(BPF|XDP)" /proc/config.gz
CONFIG_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y
# BPF subsystem
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT is not set
# CONFIG_BPF_UNPRIV_DEFAULT_OFF is not set
# CONFIG_BPF_PRELOAD is not set
# end of BPF subsystem
CONFIG_CGROUP_BPF=y
# CONFIG_XDP_SOCKETS is not set
CONFIG_NETFILTER_XT_MATCH_BPF=m
# CONFIG_BPFILTER is not set
# CONFIG_NET_CLS_BPF is not set
# CONFIG_NET_ACT_BPF is not set
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_LWTUNNEL_BPF=y
CONFIG_BPF_LIRC_MODE2=y
CONFIG_BPF_EVENTS=y
# CONFIG_BPF_KPROBE_OVERRIDE is not set
# CONFIG_TEST_BPF is not set
and other simple things just work, the failure of bpf_xdp_adjust_tail should be unexpected
- Dominant language
- C
- Stars
- 13.2k
- Forks
- 5.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 21
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/linux
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7415 · 2 comments · 1 reaction ·
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace app Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
raspberrypi/linux#7399 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
raspberrypi/linux#7357 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7054 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
raspberrypi/linux#7634 · 8 comments · 1 reaction ·
All issues in raspberrypi/linux
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·