selftests: bonding: add test for stacked bond header_parse recursion
Subsystems (4)
PATCH v4 1/1 selftests: bonding: add test for stacked bond header_parse recursion
From: Jiayuan Chen <[email protected]>
Add a selftest to reproduce the infinite recursion in bond_header_parse() when bonds are stacked (bond1 -> bond0 -> gre). When a packet is received via AF_PACKET SOCK_DGRAM on the topmost bond, dev_parse_header() calls bond_header_parse() which used skb->dev (always the topmost bond) to get the bonding struct. This caused it to recurse back into itself indefinitely, leading to stack overflow.
Before commit b7405dcf7385 ("bonding: prevent potential infinite loop in bond_header_parse()"), the test triggers:
./bond_stacked_header_parse.sh
[ 71.999481] BUG: MAX_LOCK_DEPTH too low! [ 72.000170] turning off the locking correctness validator. [ 72.001029] Please attach the output of /proc/lock_stat to the bug report [ 72.002079] depth: 48 max: 48! ...
After the fix, everything works fine:
./bond_stacked_header_parse.sh
TEST: Stacked bond header_parse does not recurse [ OK ]
---
Changes in v4:
- Fix shellcheck warnings (Simon Horman)
Changes in v3:
- Fix CONFIG_NET_IPGRE sorting order in config
Changes in v2:
- Use tcpdump + scapy instead of custom Python script
- Remove unnecessary modprobe and skip checks
- Add CONFIG_NET_IPGRE to config dependencies
v1: https://lore.kernel.org/netdev/[email protected]/T/#t
https://lore.kernel.org/netdev/CANn89iK2EURqsjtd=OVP4awYTJHGcR-UU-V9WovpWR1Z3f03oQ@mail.gmail.com/
--- .../selftests/drivers/net/bonding/Makefile | 1 + .../net/bonding/bond_stacked_header_parse.sh | 72 +++++++++++++++++++ .../selftests/drivers/net/bonding/config | 1 + 3 files changed, 74 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_stacked_header_parse.sh
tools/testing/selftests/drivers/net/bonding/Makefile +1 -0
@@ -11,6 +11,7 @@ TEST_PROGS := \ bond_macvlan_ipvlan.sh \ bond_options.sh \ bond_passive_lacp.sh \ + bond_stacked_header_parse.sh \ dev_addr_lists.sh \ mode-1-recovery-updelay.sh \ mode-2-recovery-updelay.sh \
tools/testing/selftests/drivers/net/bonding/bond_stacked_header_parse.sh new file +72 -0
72 lines not on this page · raw message
tools/testing/selftests/drivers/net/bonding/config +1 -0
@@ -14,6 +14,7 @@ CONFIG_NETCONSOLE=m CONFIG_NETCONSOLE_DYNAMIC=y CONFIG_NETCONSOLE_EXTENDED_LOG=y CONFIG_NETDEVSIM=m +CONFIG_NET_IPGRE=y CONFIG_NET_SCH_INGRESS=y CONFIG_NLMON=y CONFIG_VETH=y
Signature · 1 line
2.43.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 20 Mar 2026 10:22:39 +0800 you wrote:
From: Jiayuan Chen <[email protected]>
Add a selftest to reproduce the infinite recursion in
bond_header_parse()when bonds are stacked (bond1 -> bond0 -> gre). When a packet is received viaAF_PACKETSOCK_DGRAMon the topmost bond,dev_parse_header()callsbond_header_parse()which usedskb->dev(always the topmost bond) to get the bonding struct. This caused it to recurse back into itself indefinitely, leading to stack overflow.[...]
Here is the summary with links:
- [net-next,v4] selftests: bonding: add test for stacked bond header_parse recursion
https://git.kernel.org/netdev/net-next/c/e81cf512c1bd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html