Re: [PATCH net-next v3] selftests: bonding: add test for stacked bond header_parse recursion

From: Simon Horman

Date: Thu Mar 19 2026 - 16:37:35 EST


On Thu, Mar 19, 2026 at 11:58:56AM +0800, Jiayuan Chen wrote:
> From: Jiayuan Chen <jiayuan.chen@xxxxxxxxxx>
>
> 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 ]
>
> Cc: Jiayuan Chen <jiayuan.chen@xxxxxxxxx>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@xxxxxxxxxx>
> ---
> 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/20260316165946.46e9f8f7@xxxxxxxxxx/T/#t
> https://lore.kernel.org/netdev/CANn89iK2EURqsjtd=OVP4awYTJHGcR-UU-V9WovpWR1Z3f03oQ@xxxxxxxxxxxxxx/
> ---
> .../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

--
pw-bot: changes-requested