Re: [PATCH net v3 2/2] bonding: don't let an 802.3ad slave change its type
From: Hangbin Liu
Date: Sun Nov 22 2026 - 22:25:57 EST
On Sun, Nov 22, 2026 at 11:59:10PM +0900, Kyuwon Cho wrote:
> A bond can be a slave of another bond. Enslaving a non-Ethernet device to
> an empty inner bond changes the inner bond's type in bond_setup_by_slave()
> after NETDEV_PRE_TYPE_CHANGE, and nothing refuses that while the inner
> bond is a slave of an 802.3ad bond. The outer bond then adds the 8-byte
> lacpdu_mcast_addr to a slave whose addr_len is 16, the same global
> out-of-bounds read as when such a slave is enslaved directly:
>
> 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
> Call Trace:
> __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)
>
> Refuse NETDEV_PRE_TYPE_CHANGE for a slave of an 802.3ad bond, as team
> does for its ports. Other modes still allow it, as
> bond-eth-type-change.sh expects.
>
> Fixes: c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet devices")
> Signed-off-by: Kyuwon Cho <kyuwoncho18@xxxxxxxxx>
> ---
> drivers/net/bonding/bond_main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index bcc12ef34d9a..1a926b8d28b0 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -3981,6 +3981,10 @@ static int bond_slave_netdev_event(unsigned long event,
> slave_dbg(bond_dev, slave_dev, "%s called\n", __func__);
>
> switch (event) {
> + case NETDEV_PRE_TYPE_CHANGE:
> + if (BOND_MODE(bond) == BOND_MODE_8023AD)
> + return NOTIFY_BAD;
> + break;
> case NETDEV_UNREGISTER:
> if (bond_dev->type != ARPHRD_ETHER)
> bond_release_and_destroy(bond_dev, slave_dev);
> --
> 2.43.0
>
Hmm, I personally prefer the approach used by vlan and team, which disallows
changing the slave type after enslavement. If you think we should only disable
the 802.3ad-specific part, this change should be merged with patch 1, as they
address the same issue.
Cc Nikolay since he add the bond-eth-type-change.sh test.
Thanks
Hangbin