Skip to contentSkip to conversation

selftests: bonding: add test for stacked bond header_parse recursion

PATCH Superseded Jiayuan Chen 2 participants 2 messages Mar 17 – Mar 19

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 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  | 69 +++++++++++++++++++
 .../selftests/drivers/net/bonding/config      |  1 +
 3 files changed, 71 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/bonding/bond_stacked_header_parse.sh
tools/testing/selftests/drivers/net/bonding/Makefile +1 -0
index 6c5c60adb5e8..9af5f84edd37 100644
@@ -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 +69 -0

69 lines not on this page · raw message

tools/testing/selftests/drivers/net/bonding/config +1 -0
index 991494376223..14f21f0e4d2f 100644
@@ -13,6 +13,7 @@ CONFIG_NET_CLS_MATCHALL=m
 CONFIG_NETCONSOLE=m
 CONFIG_NETCONSOLE_DYNAMIC=y
 CONFIG_NETCONSOLE_EXTENDED_LOG=y
+CONFIG_NET_IPGRE=y
 CONFIG_NETDEVSIM=m
 CONFIG_NET_SCH_INGRESS=y
 CONFIG_NLMON=y
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 5 lines · On Tue, 17 Mar 2026 11:14:30 +0800 Jiayuan Chen wrote:

CONFIG_NETCONSOLE_EXTENDED_LOG=y
+CONFIG_NET_IPGRE=y
CONFIG_NETDEVSIM=m
CONFIG_NET_SCH_INGRESS=y
CONFIG_NLMON=y

Sorry this also has to be sorted and the special characters are a bit tricky. As you can see from CONFIG_NET_SCH_INGRESS the sorting algo considers _ to be after letters, so you need to move the new addition down.

When you repost you can target net-next, FWIW.
If the selftest is part of the same series as the fix we let them go together but standalone selftest postings should go to net-next.

Signature · 1 line
pw-bot: cr