* [PATCH net v2 0/2] team: fix header_ops type confusion and add selftest
@ 2026-03-17 12:45 Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 1/2] team: fix header_ops type confusion with non-Ethernet ports Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer Jiayuan Chen
0 siblings, 2 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-03-17 12:45 UTC (permalink / raw)
To: netdev
Cc: Jiayuan Chen, Jiri Pirko, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Shuah Khan,
linux-kernel, linux-kselftest
Hi,
This patch series fixes a panic reported by syzkaller in the team/bond/gre
stacked non-Ethernet configuration:
https://syzkaller.appspot.com/bug?extid=3d8bc31c45e11450f24c
The first patch fixes the header_ops type confusion / parse recursion context
issue in team. The second patch adds a selftest to reproduce the reported
scenario and prevent regressions in the future.
Thanks.
---
Changes in v2:
- The same fix approach was applied to bonding first, but could cause
infinite recursion in bond_header_parse(). Eric spotted the issue and
fixed it in:
b7405dcf7385 ("bonding: prevent potential infinite loop in bond_header_parse()")
After that fix landed, we continue with the same approach to fix team.
v1: https://lore.kernel.org/netdev/20260314062306.212765-1-jiayuan.chen@linux.dev/
Jiayuan Chen (2):
team: fix header_ops type confusion with non-Ethernet ports
selftests: team: add non-Ethernet header_ops reproducer
drivers/net/team/team_core.c | 60 ++++++++++++++++++-
.../selftests/drivers/net/team/Makefile | 1 +
.../testing/selftests/drivers/net/team/config | 2 +
.../drivers/net/team/non_ether_header_ops.sh | 40 +++++++++++++
4 files changed, 102 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 1/2] team: fix header_ops type confusion with non-Ethernet ports
2026-03-17 12:45 [PATCH net v2 0/2] team: fix header_ops type confusion and add selftest Jiayuan Chen
@ 2026-03-17 12:45 ` Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer Jiayuan Chen
1 sibling, 0 replies; 4+ messages in thread
From: Jiayuan Chen @ 2026-03-17 12:45 UTC (permalink / raw)
To: netdev
Cc: Jiayuan Chen, syzbot+3d8bc31c45e11450f24c, Jiayuan Chen,
Jiri Pirko, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Shuah Khan, linux-kernel,
linux-kselftest
From: Jiayuan Chen <jiayuan.chen@shopee.com>
Similar to commit 950803f72547 ("bonding: fix type confusion in
bond_setup_by_slave()") team has the same class of header_ops type
confusion.
For non-Ethernet ports, team_setup_by_port() copies port_dev->header_ops
directly. When the team device later calls dev_hard_header() or
dev_parse_header(), these callbacks can run with the team net_device
instead of the real lower device, so netdev_priv(dev) is interpreted as
the wrong private type and can crash.
Fix this by introducing team header_ops wrappers for create/parse,
selecting a team port under RCU, and calling the lower device callbacks
with port->dev, so each callback always sees the correct net_device
context.
Also pass the selected lower device to the lower parse callback, so
recursion is bounded in stacked non-Ethernet topologies and parse
callbacks always run with the correct device context.
Fixes: 1d76efe1577b ("team: add support for non-ethernet devices")
Reported-by: syzbot+3d8bc31c45e11450f24c@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/69b46af7.050a0220.36eb34.000e.GAE@google.com/T/
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
---
drivers/net/team/team_core.c | 60 +++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index b7282f5c9632..b3f659ed06ca 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -2058,6 +2058,64 @@ static const struct ethtool_ops team_ethtool_ops = {
* rt netlink interface
***********************/
+/* For tx path we need a linkup && enabled port; for parse any port suffices. */
+static struct team_port *team_header_port_get_rcu(struct team *team, bool txable)
+{
+ struct team_port *port;
+
+ list_for_each_entry_rcu(port, &team->port_list, list) {
+ if (!txable || team_port_txable(port))
+ return port;
+ }
+
+ return NULL;
+}
+
+static int team_header_create(struct sk_buff *skb, struct net_device *team_dev,
+ unsigned short type, const void *daddr,
+ const void *saddr, unsigned int len)
+{
+ struct team *team = netdev_priv(team_dev);
+ const struct header_ops *port_ops;
+ struct team_port *port;
+ int ret = 0;
+
+ rcu_read_lock();
+ port = team_header_port_get_rcu(team, true);
+ if (port) {
+ port_ops = READ_ONCE(port->dev->header_ops);
+ if (port_ops && port_ops->create)
+ ret = port_ops->create(skb, port->dev,
+ type, daddr, saddr, len);
+ }
+ rcu_read_unlock();
+ return ret;
+}
+
+static int team_header_parse(const struct sk_buff *skb, const struct net_device *dev,
+ unsigned char *haddr)
+{
+ struct team *team = netdev_priv(dev);
+ const struct header_ops *port_ops;
+ struct team_port *port;
+ int ret = 0;
+
+ rcu_read_lock();
+ port = team_header_port_get_rcu(team, false);
+ if (port) {
+ port_ops = READ_ONCE(port->dev->header_ops);
+ if (port_ops && port_ops->parse)
+ ret = port_ops->parse(skb, port->dev, haddr);
+ }
+ rcu_read_unlock();
+ return ret;
+}
+
+static const struct header_ops team_header_ops = {
+ .create = team_header_create,
+ .parse = team_header_parse,
+};
+
static void team_setup_by_port(struct net_device *dev,
struct net_device *port_dev)
{
@@ -2066,7 +2124,7 @@ static void team_setup_by_port(struct net_device *dev,
if (port_dev->type == ARPHRD_ETHER)
dev->header_ops = team->header_ops_cache;
else
- dev->header_ops = port_dev->header_ops;
+ dev->header_ops = port_dev->header_ops ? &team_header_ops : NULL;
dev->type = port_dev->type;
dev->hard_header_len = port_dev->hard_header_len;
dev->needed_headroom = port_dev->needed_headroom;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer
2026-03-17 12:45 [PATCH net v2 0/2] team: fix header_ops type confusion and add selftest Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 1/2] team: fix header_ops type confusion with non-Ethernet ports Jiayuan Chen
@ 2026-03-17 12:45 ` Jiayuan Chen
2026-03-19 1:18 ` Jakub Kicinski
1 sibling, 1 reply; 4+ messages in thread
From: Jiayuan Chen @ 2026-03-17 12:45 UTC (permalink / raw)
To: netdev
Cc: Jiayuan Chen, Jiayuan Chen, Jiri Pirko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, linux-kernel, linux-kselftest
From: Jiayuan Chen <jiayuan.chen@shopee.com>
Add a team selftest that sets up:
g0 (gre) -> b0 (bond) -> t0 (team)
and triggers IPv6 traffic on t0. This reproduces the non-Ethernet
header_ops confusion scenario and protects against regressions in stacked
team/bond/gre configurations.
Using this script, the panic reported by syzkaller can be reproduced [1].
After the fix:
# ./non_ether_header_ops.sh
PASS: non-Ethernet header_ops stacking did not crash
[1] https://syzkaller.appspot.com/bug?extid=3d8bc31c45e11450f24c
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
---
.../selftests/drivers/net/team/Makefile | 1 +
.../testing/selftests/drivers/net/team/config | 2 +
| 40 +++++++++++++++++++
3 files changed, 43 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh
diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/testing/selftests/drivers/net/team/Makefile
index 45a3e7ad3dcb..02d6f51d5a06 100644
--- a/tools/testing/selftests/drivers/net/team/Makefile
+++ b/tools/testing/selftests/drivers/net/team/Makefile
@@ -3,6 +3,7 @@
TEST_PROGS := \
dev_addr_lists.sh \
+ non_ether_header_ops.sh \
options.sh \
propagation.sh \
refleak.sh \
diff --git a/tools/testing/selftests/drivers/net/team/config b/tools/testing/selftests/drivers/net/team/config
index 558e1d0cf565..40fdd5fbcbdb 100644
--- a/tools/testing/selftests/drivers/net/team/config
+++ b/tools/testing/selftests/drivers/net/team/config
@@ -1,5 +1,7 @@
+CONFIG_BONDING=y
CONFIG_DUMMY=y
CONFIG_IPV6=y
+CONFIG_NET_IPGRE=y
CONFIG_MACVLAN=y
CONFIG_NETDEVSIM=m
CONFIG_NET_TEAM=y
--git a/tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh b/tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh
new file mode 100755
index 000000000000..19bd57f40688
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/team/non_ether_header_ops.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Reproduce the non-Ethernet header_ops confusion scenario with:
+# g0 (gre) -> b0 (bond) -> t0 (team)
+#
+# Before the fix, direct header_ops inheritance in this stack could call
+# callbacks with the wrong net_device context and crash.
+
+lib_dir=$(dirname "$0")
+source "$lib_dir"/../../../net/lib.sh
+
+trap cleanup_all_ns EXIT
+
+setup_ns ns1
+
+ip -n "$ns1" link add d0 type dummy
+ip -n "$ns1" addr add 10.10.10.1/24 dev d0
+ip -n "$ns1" link set d0 up
+
+ip -n "$ns1" link add g0 type gre local 10.10.10.1
+ip -n "$ns1" link add b0 type bond mode active-backup
+ip -n "$ns1" link add t0 type team
+
+ip -n "$ns1" link set g0 master b0
+ip -n "$ns1" link set b0 master t0
+
+ip -n "$ns1" link set g0 up
+ip -n "$ns1" link set b0 up
+ip -n "$ns1" link set t0 up
+
+# GRE makes team inherit IFF_POINTOPOINT|IFF_NOARP, so IPv4 skips
+# dev_hard_header() entirely... use IPv6 NDP which still calls it.
+ip -n "$ns1" -6 addr add 2001:db8:1::1/64 dev t0 nodad
+for i in $(seq 1 20); do
+ ip netns exec "$ns1" ping -6 -I t0 ff02::1 -c1 -W1 &>/dev/null || true
+done
+
+echo "PASS: non-Ethernet header_ops stacking did not crash"
+exit "$EXIT_STATUS"
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer
2026-03-17 12:45 ` [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer Jiayuan Chen
@ 2026-03-19 1:18 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-03-19 1:18 UTC (permalink / raw)
To: Jiayuan Chen
Cc: netdev, Jiayuan Chen, Jiri Pirko, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Shuah Khan, linux-kernel,
linux-kselftest
On Tue, 17 Mar 2026 20:45:54 +0800 Jiayuan Chen wrote:
> CONFIG_IPV6=y
> +CONFIG_NET_IPGRE=y
> CONFIG_MACVLAN=y
> CONFIG_NETDEVSIM=m
Again the sort :)
Please use the validate_* scripts from here:
https://github.com/linux-netdev/nipa/tree/main/tests/patch/check_selftest
they take the file name as the only arg and will tell if you its sorted.
For whatever definition of "sorted" we adopted...
--
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-19 1:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 12:45 [PATCH net v2 0/2] team: fix header_ops type confusion and add selftest Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 1/2] team: fix header_ops type confusion with non-Ethernet ports Jiayuan Chen
2026-03-17 12:45 ` [PATCH net v2 2/2] selftests: team: add non-Ethernet header_ops reproducer Jiayuan Chen
2026-03-19 1:18 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox