๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20687

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

#20687
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 03:32
108 lines
11968 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 patch moves the "8023AD mode requires Ethernet devices" check in
bond_enslave() above the bond type handling. The check now applies to
every slave, not only to a first slave that changes the bond's type. It
targets a KASAN global-out-of-bounds read in bond_open(), where
dev_mc_add() copies a 16-byte addr_len from the 8-byte lacpdu_mcast_addr.

> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 042d7c75548fa..bcc12ef34d9ab 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1951,6 +1951,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>  		return -EPERM;
>  	}
>  
> +	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]
Does this fully close the out-of-bounds read on lacpdu_mcast_addr? The
check only looks at slave_dev->type when the device is enslaved. A slave
that is itself a bond can still change type afterwards, while it stays a
slave of the 802.3ad bond.

Here is a possible sequence:

  1) Create B1 in 802.3ad mode and B2 in active-backup mode. B2 is
     ARPHRD_ETHER because bonds are created with ether_setup.
  2) Enslave B2 into B1. Bond masters are allowed as slaves, and B2 is
     ARPHRD_ETHER, so the new check passes.
  3) Enslave an ip6tnl device (ARPHRD_TUNNEL6, addr_len 16) into B2.

Step 3 goes through:

bond_enslave(B2, ip6tnl)
  call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, B2)
    bond_netdev_event()
      bond_master_netdev_event()   returns NOTIFY_DONE
      bond_slave_netdev_event()    returns NOTIFY_DONE, no PRE_TYPE_CHANGE case
  bond_setup_by_slave(B2, ip6tnl)
    bond_dev->type     = slave_dev->type;      /* ARPHRD_TUNNEL6 */
    bond_dev->addr_len = slave_dev->addr_len;  /* 16 */

Nothing in bonding vetoes the type change, so B2 is now a TUNNEL6 slave
of the 802.3ad bond B1. Setting B1 down and then up again reaches the
same sink as in the commit message:

bond_open(B1)
  dev_mc_add(slave->dev, lacpdu_mcast_addr)
    __dev_mc_add()
      __hw_addr_add_ex(&dev->mc, addr, dev->addr_len, ...)
        memcpy(ha->addr, addr, addr_len)   /* 16 bytes from an 8-byte global */

with:

drivers/net/bonding/bond_3ad.c:
const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = {

bond_hw_addr_flush() has the same problem through
dev_mc_del(slave_dev, lacpdu_mcast_addr). The bytes read past the end of
the global end up in B2's mc list, and /proc/net/dev_mcast prints them.

A team device used as the inner device should follow the same path,
because team_dev_type_check_change() also relies on the notifier chain.

Other upper drivers block type changes of their lower devices. For
example, team_device_event():

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

Bridge, macvlan, ipvlan, hsr and vlan do the same.

Could bond_slave_netdev_event() refuse NETDEV_PRE_TYPE_CHANGE, at least
in 802.3ad mode? Another option would be to check the slave's addr_len
before dev_mc_add()/dev_mc_del() of lacpdu_mcast_addr.

>  	/* set bonding device ether type by slave - bonding netdevices are
>  	 * created with ether_setup, so when the slave type is not ARPHRD_ETHER
>  	 * there is a need to override some of the type dependent attribs/funcs.

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179505868590.3571070.12381528230330714812%40gmail.com
Technical Details
Message-ID: <179540476963.3135.15854448705865137311@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368995-linux-kernel-netdev=dewy.ru
References: <179505868590.3571070.12381528230330714812@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368995-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] bonding: reject a non-Ethernet 802.3ad slave even
 when the type matches
Date: Mon, 23 Nov 2026 03:32:49 +0000
Organization: Usenet Network
Message-ID: <179540476963.3135.15854448705865137311@kernel.org>
References: <179505868590.3571070.12381528230330714812@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3782459"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2NttSjGb07Rb0nGZWljvyimPRlw= sha256:9vTYEJ6qu+tL3ovWYIoDkuYEA/6bkZAoLF3iaI+lGGY=
	sha1:LKrFiBEhyBK5DlzjdKhsqW5GhM0= sha256:uDn2Qp6X61rvlT7kVXN0J4SR4DRNbn83hvSa+t1rUCg=
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 9BA8B125D87; Mon, 23 Nov 2026 06:33:15 +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 XDXpKvIDOuPq;
	Mon, 23 Nov 2026 06:33:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368995-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C67EE125D8A; Mon, 23 Nov 2026 06:32:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 62C2D29455; Mon, 23 Nov 2026 03:32:57 +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=1795404777;
	b=BO5pnaBaztLXgRuNvFb6F7XLJCt3dh/7/n5XM2bD5TWnSK+inQDtB+T/HjPT4k1RAKaD
	 5/iysjC+2RClhSez4Ek626lWy7q/A/blYSjufHtGbA4yvAnzRxMS4SYNUYBfTvspkKmZj
	 cJgmYPimvGC4H0byp56c4IJb/4XwqJVT3tK/eSoG+Ri8dreliGPDadMNJJLqo/mdctq9Y
	 KWFzZembNTyXsJ//LuUWuMtdjRo2DGQWSeyx6teuYHvRNXGUZNU980Q0edpTco60Eikmm
	 HUsDY5bEP80n+PRsq0DgbI2TbZgIejHDcYY+lgk0cxO9pKlzyryXLZ/sxtwejZf0aNA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795404777;
	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=kBqe9Dl7xjSgmQlMJ6gpivRKSw2tHUzsUfeHJzmYSX0=;
	b=amEzD8cGgCdNWISc3fTm0YUWg8pbXrDIwy4bOCh1FgJzQcMDtY0aS1aWIR4+bLLW5WFm
	 vEps3CvkpvVF9goOwFhaxr4Y5DtYBtGi4/Lvlz8zwwlUzpTFG88KW8S9IKAmftf16ePRM
	 hrQCQvjf1DdncyjiAIv9TnoonLhTbW0p4LAV++WDO4BENKG265lfGeJLdVnfoVMRSdFfZ
	 9q/taWi9PVm3ZW3LnNq882jEKJ4LVfJewpZ17WnRl9dEaEkHvMG1MjzX+dzl85I1tX3dn
	 ybx4qbX5P/iKOBYT6dLw2cd13IG66pTafVfhR2y+YIJWCKCLkSVP5APCq2QpQT8IOKw==
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=Y7iJWcjh;
	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 1ECC8606A320;
	Mon, 23 Nov 2026 03:32:57 +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=Y7iJWcjh
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=1795404771;
	b=G8Km+OrTgPYHRLqRTIHgfZERTkDsnALVlmH19dlREO2CMmhMpctdeOBHPYtryf/dR9Gr
	 HNJLHfcZ+1Q+0beOOLCfqSkD8qZJWx6ogRVuAXQxKmCgdLpuCbFOXhY+DRTrJkm2dBooB
	 FSNMb+byWkaSQicUBOHLipjlrY6IW0v+cwcc8pZ7WV0MoaAFcKcPgCYWcE2aaLad8EWgF
	 Iu7Cz6KwbsaooVJw+pkvCjmMPb19D/qyKe9SPv1gW9Ct74+broFvg3crKClsEnxIjuMzY
	 TrPllup7zpy86FVAYT6RCpT37mjH4cuZUe4HLsJUXn6Pf0rh0/Hkf3JYIww3S2iKkBQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795404771;
	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=kBqe9Dl7xjSgmQlMJ6gpivRKSw2tHUzsUfeHJzmYSX0=;
	b=wvbyT2bi8R+9Az2iPaTZwMxTcARUbyGRu2QVuX4kzSuVQbF7RW2hVHn7AzGnNdQHj2pC
	 c/1OMMd2hT+mXB58D/gybsCFkUE0xG+prn9mKWN0zYighIT1v1D8MtNtfe3OvX+w3aU5e
	 nevC94yIpBKtGrq04DhKQ7IXYsIVQAMKylgkSaGLA2q3QeGhSaflGSOj9LrS9vS/zGMtg
	 kIAUfSEvSBZPZDSEUZ5CsWGx7Vr7Kv7FoWy4QD0qeZQ9E1mvmGXFb8TFaSCdvFNtsLVxw
	 JrTH+iUmTP60qeUWGQohRF61itKbBnkVtLFM7D6qDAsz89BsNleFXKO5XfWUwAg8ilg==
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=Y7iJWcjh;
	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 3B25A606A31E;
	Mon, 23 Nov 2026 03:32:50 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E7DF1F000CA;
	Mon, 23 Nov 2026 03:32:50 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795404770;
	bh=kBqe9Dl7xjSgmQlMJ6gpivRKSw2tHUzsUfeHJzmYSX0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Y7iJWcjh04wCGKVPx7raF2JWc/HbkfzOOSasgMbRVafFItfolMiKnVi5YFheqqJsX
	 Tn+Q4HzRT/QIrqJUw6nD6sn9hkad9OvZ7OEDiN+nlCwgL2BKiaYXwRGEwkbFkk491v
	 ecjlgxYiX/4j/h0NW0JJtpA7geXXJ7v8s508A7S7GrK0NRhKuXDEsr3jHbTkBzjHox
	 +KYZIGFssV1O80ui6KBsEkJrykv7aOrXUKkf0yHht0z3aIMwpaXeHBAX9TvWvXlL5G
	 f737O6cxev0t4Ht9gccqt00uApy8TjDQsQthXOT1yhMVqjdC5nUMj6/RczFWzK/UUV
	 MXWXp31kS9gdA==
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: <179505868590.3571070.12381528230330714812@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