All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Kyuwon Cho <kyuwoncho18@gmail.com>
Cc: netdev@vger.kernel.org, Jay Vosburgh <jv@jvosburgh.net>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] bonding: reject a non-Ethernet 802.3ad slave even when the type matches
Date: Mon, 23 Nov 2026 11:17:50 +0800	[thread overview]
Message-ID: <20261123031750.GD10218@Liu-laptop> (raw)
In-Reply-To: <179535729502.2645501.7669047222441539373@gmail.com>

On Sun, Nov 22, 2026 at 11:59:09PM +0900, Kyuwon Cho wrote:
> Commit c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet
> devices") rejects a non-Ethernet first slave in 802.3ad mode, but only
> when enslaving it changes the bond's type. A bond keeps the type of its
> last slave after that slave is released, so a bond that once had an
> ARPHRD_TUNNEL6 slave can be set to 802.3ad and take another TUNNEL6
> device, such as a second bond prepared the same way, without the check.
> bond_open() then adds the 8-byte lacpdu_mcast_addr to that slave with
> dev_mc_add(), which copies the slave's 16-byte addr_len:
> 
>   BUG: KASAN: global-out-of-bounds in __hw_addr_add_ex (net/core/dev_addr_lists.c:102 net/core/dev_addr_lists.c:157)
>   Read of size 16 at addr ffffffff878a2940 by task test/114
>   Call Trace:
>    <TASK>
>    __hw_addr_add_ex (net/core/dev_addr_lists.c:102 net/core/dev_addr_lists.c:157)
>    dev_mc_add (net/core/dev_addr_lists.c:1036 net/core/dev_addr_lists.c:1054)
>    bond_open (drivers/net/bonding/bond_main.c:4405)
>    __dev_open (net/core/dev.c:1762)
>    __dev_change_flags (net/core/dev.c:10022)
>    netif_change_flags (net/core/dev.c:10087)
>    do_setlink.isra.0 (net/core/rtnetlink.c:3294)
>    rtnl_setlink (net/core/rtnetlink.c:3633)
> 
> An unprivileged user can set this up in its own user and network
> namespace.
> 
> Check that an 802.3ad slave is an Ethernet device before the type
> handling, for every slave.
> 
> Fixes: c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet devices")
> Suggested-by: Jay Vosburgh <jv@jvosburgh.net>
> Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
> Reviewed-by: Eric Dumazet <edumazet@kernel.org>
> ---
>  drivers/net/bonding/bond_main.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 042d7c75548f..bcc12ef34d9a 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;
> +	}
> +
>  	/* 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.
> @@ -1960,12 +1967,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>  	 */
>  	if (!bond_has_slaves(bond)) {
>  		if (bond_dev->type != slave_dev->type) {
> -			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;
> -			}
>  			slave_dbg(bond_dev, slave_dev, "change device type from %d to %d\n",
>  				  bond_dev->type, slave_dev->type);
>  
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

  reply	other threads:[~2026-11-23  3:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 14:59 [PATCH net v3 0/2] bonding: keep non-Ethernet slaves out of 802.3ad bonds Kyuwon Cho
2026-11-22 14:59 ` [PATCH net v3 1/2] bonding: reject a non-Ethernet 802.3ad slave even when the type matches Kyuwon Cho
2026-11-23  3:17   ` Hangbin Liu [this message]
2026-11-22 14:59 ` [PATCH net v3 2/2] bonding: don't let an 802.3ad slave change its type Kyuwon Cho
2026-11-23  3:25   ` Hangbin Liu
2026-11-23  4:29     ` Kyuwon Cho
2026-11-23 12:43       ` Nikolay Aleksandrov
2026-11-23 12:46         ` Nikolay Aleksandrov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123031750.GD10218@Liu-laptop \
    --to=hangbin.liu@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jv@jvosburgh.net \
    --cc=kuba@kernel.org \
    --cc=kyuwoncho18@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.