๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20416

Re: [PATCH net] bonding: reject a non-Ethernet 802.3ad slave even when the type matches

#20416
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 13:02
110 lines
11893 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete.

--

bonding: reject a non-Ethernet 802.3ad slave even when the type matches

This moves the 802.3ad Ethernet-only check in bond_enslave() so that it
runs for every first slave, not only when enslaving changes the bond's
type. The goal is to stop the global out-of-bounds read of
lacpdu_mcast_addr in bond_open() when a slave with a 16-byte addr_len ends
up in an 802.3ad bond.

> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 042d7c75548fa..f2e645f869b13 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1959,13 +1959,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>  	 * ether type (eg ARPHRD_ETHER and ARPHRD_INFINIBAND) share the same bond
>  	 */
>  	if (!bond_has_slaves(bond)) {
> +		if (slave_dev->type != ARPHRD_ETHER &&
> +		    BOND_MODE(bond) == BOND_MODE_8023AD) {
> +			SLAVE_NL_ERR(bond_dev, slave_dev, extack,
> +				     "8023AD mode requires Ethernet devices");
> +			return -EINVAL;
> +		}

[Severity: High]
Is this check enough to keep a non-Ethernet slave out of an 802.3ad bond?
It only looks at the slave's type when the slave is enslaved. A slave that
is itself a bond can still change type after that.

Consider this sequence:

  ip link add bondA type bond mode 802.3ad
  ip link add bondB type bond mode active-backup
  ip link set bondB master bondA     <- bondB is ARPHRD_ETHER, passes
  ip link set ip6tnl0 master bondB   <- bondB has no slaves yet

The second enslave goes through bond_enslave(bondB), which sends
NETDEV_PRE_TYPE_CHANGE for bondB:

	res = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
				       bond_dev);

bond_netdev_event() passes the event to bond_master_netdev_event() and
bond_slave_netdev_event(). Neither one has a NETDEV_PRE_TYPE_CHANGE case,
so both reach:

	default:
		break;
	}

	return NOTIFY_DONE;

vlan_device_event() only refuses this when VLAN upper devices exist. So
bond_setup_by_slave() goes ahead and sets bondB->type to ARPHRD_TUNNEL6
and bondB->addr_len to 16, while bondB is still a slave of bondA.

When bondA is brought up, bond_open() does:

	bond_for_each_slave(bond, slave, iter)
		dev_mc_add(slave->dev, lacpdu_mcast_addr);

but lacpdu_mcast_addr in bond_3ad.c is only 8 bytes:

	const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = {

Does this lead to the same global out-of-bounds read as the KASAN report
in the commit message?

If bondA is already up, a later release of bondB has the same problem.
bond_hw_addr_flush() calls dev_mc_del(slave_dev, lacpdu_mcast_addr),
which compares 16 bytes against the same 8-byte array.

Changing the type of an enslaved bond seems to be supported behaviour.
bond_test_enslave_type_change() in
tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh
enslaves one bond to another, then enslaves a non-Ethernet device to the
inner bond. In its successful variant, the test expects the type change
to stick.

For comparison, team_device_event() in drivers/net/team/team_core.c
refuses this event for its ports:

	case NETDEV_PRE_TYPE_CHANGE:
		/* Forbid to change type of underlaying device */
		return NOTIFY_BAD;

Should bond_slave_netdev_event() also veto NETDEV_PRE_TYPE_CHANGE? That
could apply only when the bond is in 802.3ad mode and the new type is not
Ethernet, or, as team does, whenever the slave's type would no longer
match bond_dev->type.

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179500849159.1877154.14715369660816392826%40gmail.com
Technical Details
Message-ID: <179535255333.3135.10581087211469618015@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368683-linux-kernel-netdev=dewy.ru
References: <179500849159.1877154.14715369660816392826@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368683-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] bonding: reject a non-Ethernet 802.3ad slave even
 when the type matches
Date: Sun, 22 Nov 2026 13:02:33 +0000
Organization: Usenet Network
Message-ID: <179535255333.3135.10581087211469618015@kernel.org>
References: <179500849159.1877154.14715369660816392826@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3637718"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:bSsk6Y+RMhsEX8v4RFBRW3N4QYM= sha256:U2acovrx5t3JXG+hy4hGl1yrOtSxJO1m4tAAtDLqx4E=
	sha1:LBSFdIBjE/QenVZoCmGPPZyBDuM= sha256:k4zidqPAa5irTf7/8xOYyM5d3dgDW1aESZaaGN0qDQs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 7086B125D77; Sun, 22 Nov 2026 16:02:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id j02LbtKJvr-2;
	Sun, 22 Nov 2026 16:02:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368683-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 61A58125D76; Sun, 22 Nov 2026 16:02:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 16B6E2C79A; Sun, 22 Nov 2026 13:02:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795352555;
	b=TNt50m/0j7DIbtXn/WQwjg7V5QWZXtzOfkiTqn4f2wbGxsYsgLgL80XXvlZ/p/GmQtMz
	 3vokAKT1xcKFWDfyX3dJvdw9/HPTvcXN7yXx+tnU8Q683E2ZrDn8aZMulo9LSrGsVas5u
	 8J9vhBN9hHzsYy42mUCvloZJ2IWlPZMPQ/+sngDGvfUQSo4RRnO0Kr03D5Q2xPmktYLKO
	 seaAhwoDX9aAOBK4M0Ii2WdjueSOltV4iUWPINNDE1HOzYxbsnR/v8ppdVZe5T0CvjmIf
	 2d9Gxfqa5Y/0Y6sLdwFyZbkLbOcKod/6vV5jVL3mbgUn/CN20L+t8lqaDGvb53XNkdg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795352555;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=Ab/ahYb+D8PHWWcmTQ2KYtkHbZbbfYycn1dhmK2jBrU=;
	b=HPLDKK8Ox7ZOLPXBAJfgmF3B1++V4f+EoIL0kawVJiSF1RCYN2gnAGvoxzkN5koWknb3
	 PZDNstsK9R+p9XmyJqLG+y+3/hQdZiDc9WKtIGMdRHu50yEYaBir4tRNsPdukNvr3odef
	 /b22xGx7upmZSusn80RHUbRGXio3Pvb6r0oBJVk8vW2CDWre4zvTBa4ITbDVJfCLXM6NQ
	 hwYSH4NqKnHy6Lg8Arfkc32QNCa5fxk+91I1yDwtcfhyBvQ0dqKeAFMBjDP8pTmJ30MCx
	 F0alBOYMnfjB8F7W9jvOoYjQzbNcFYIbYcdSv/5qTmV6b3dZ1818GJpdDHnVfkVlLXg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vqf5iMms;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CCE36606A332;
	Sun, 22 Nov 2026 13:02:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vqf5iMms
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795352555;
	b=KUtncUXpu2pDRBPP5i6ng+ff0O917BkGnlcyCr1DSBWb3DzYdjXae+p+GXhBAi0Vl4Uf
	 1bF43TTmm0nbXSY67WTnwl6jVHXUWf8LVpmQh3e3RaPoQOU8ACn1dIYQaJvRlb6x+w+01
	 WTHarqEwwGVsfH0sxxaEFqZCOV2ZZE/GlCj+bwqnyAySgjBjgux88vAgwSkQlNlatdWPo
	 cv4j+a4OODBGzSiMq5bLYjfPm+7qxgI31iXqDjZ+imse5cH7j97p5ZPGSP7rlyyUW79oD
	 2AlHho9xOlQabZNvd+zpmiBDgmWlz48DC1Rw0hC+pxeWP516P9gPTj0NxV+hd8WjU8A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795352555;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=Ab/ahYb+D8PHWWcmTQ2KYtkHbZbbfYycn1dhmK2jBrU=;
	b=SRzyiSv1hzGwWI93x61H2C9AuRX4PLeV50T20blMZ9v9sWSQdWGrgRcTwhgmYF+83tTf
	 hHoMmDzDRbso/tb7Tznfw+FjzCCYgjvnobEF1zBVGaSi+DVqiHTrES1N+q3//WwmE0UmY
	 EF9gNN+yo/9COsfsjn9j1liRqvyLeDSpzTFm8HvgWHp4SviutkkjJkBxZBVrffsqyerP1
	 69XeBe7ntkTc2HgYBwqovSS9Z9Kbif87n7irqrNKeB17S7zJ5AVHMEpsQtZvleLEYwONB
	 0QfMRlucjvKdAwE6fp402Hb5/qLWs9EBPgo4LE8Mj2WSDNJAM7mjiDI9aKah5IuRynA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vqf5iMms;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E989D606A320;
	Sun, 22 Nov 2026 13:02:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C34301F000C6;
	Sun, 22 Nov 2026 13:02:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795352554;
	bh=Ab/ahYb+D8PHWWcmTQ2KYtkHbZbbfYycn1dhmK2jBrU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Vqf5iMmsrMAYqIcpO8/6njH6L1Mq6oHdvgAL8i3VFDrsOkCsiwkeg/H4lCYumVRMC
	 j951gLzLZxjZ+ZuR71ZL1ujFGBD8VlvMz1NNNP6V8IdMjhtDU7oO8iL6iKHEizWRdP
	 hC7daoxexmuUC4IfoJLFdhIRwZ0B6R12q6blc3PHgMBmI5cPSy9eaTu4/owtv023gG
	 ogxIioHA106J/5cCmLWCcfn2ZXFYIUasNpUpcdqamUGkY2xHlkcmUnRI7JCa9OGQvF
	 mlX1jndjNm7Mq5iASNlEVS7UI7cE9Wd6Cl+sWw5TvhBXENquggwScusYcMUpJIc5TM
	 1F7qMz0Ei5Q1Q==
X-Cc: netdev@vger.kernel.org, jv@jvosburgh.net, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <179500849159.1877154.14715369660816392826@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list