selftests: bonding: add test for stacked bond header_parse recursion
Subsystems (4)
PATCH v3 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 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 | 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
@@ -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
@@ -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
Simon Horman
reviewerQuoted 36 lines · Jiayuan Chen
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.Before commit
b7405dcf7385("bonding: prevent potential infinite loop inbond_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 bondheader_parsedoes not recurse [ OK ]Cc Jiayuan Chen <[email protected]>Signed-off-by Jiayuan Chen <[email protected]>---
Changes in v3:
- FixCONFIG_NET_IPGREsorting order in configChanges in v2:
- Use tcpdump + scapy instead of custom Python script
- Remove unnecessary modprobe and skip checks
- AddCONFIG_NET_IPGREto config dependencies
Quoted 5 lines
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 +++++++++++++++++++
Please take some time to run shellcheck over bond_stacked_header_parse.sh and make it shellcheck clean.
I suggest that can be achieved by adding the following somewhere:
# shellcheck disable=SC2034,SC2329
Signature · 1 line
pw-bot: changes-requested