* [PATCH net-next v4 0/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds @ 2026-11-24 5:13 Kyuwon Cho 2026-11-24 5:13 ` [PATCH net-next v4 1/1] " Kyuwon Cho 0 siblings, 1 reply; 4+ messages in thread From: Kyuwon Cho @ 2026-11-24 5:13 UTC (permalink / raw) To: netdev Cc: Jay Vosburgh, Hangbin Liu, Nikolay Aleksandrov, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel bond_open() adds the 8-byte lacpdu_mcast_addr to every slave of an 802.3ad bond, so a slave whose addr_len is 16, such as an ip6tnl device, makes dev_mc_add() read past it. The patch rejects such a slave at enslave time in every case and stops a slave of an 802.3ad bond from changing its type afterwards. The issue was found by an LLM-guided test generator that we are developing as a research prototype. v4: - Target net-next (Nikolay). - Merge the two patches into one (Hangbin). - Drop the Reviewed-by tags of Eric and Hangbin, as the patch changed. - Keep the type change veto to 802.3ad. Refusing type changes after enslave in every mode, as Nikolay noted, would only affect nested non-Ethernet setups and can be discussed separately. v3: https://lore.kernel.org/netdev/179535729502.2645501.5219010464870440@gmail.com/ - Add a patch that refuses NETDEV_PRE_TYPE_CHANGE for 802.3ad slaves (Sashiko review). v2: https://lore.kernel.org/netdev/179505868590.3571070.12381528230330714812@gmail.com/ - Move the check above the type handling, as Jay suggested. v1: https://lore.kernel.org/netdev/179500849159.1877154.14715369660816392826@gmail.com/ The patch was written with LLM assistance; we reviewed and tested it. With it, neither the direct nor the nested reproducer triggers the report. Enslaving Ethernet devices into an 802.3ad bond, a non-Ethernet device into an active-backup bond, and the type change of a bond enslaved to a balance-rr bond, as in bond-eth-type-change.sh, work as before. Kyuwon Cho (1): bonding: keep non-Ethernet slaves out of 802.3ad bonds drivers/net/bonding/bond_main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v4 1/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds 2026-11-24 5:13 [PATCH net-next v4 0/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds Kyuwon Cho @ 2026-11-24 5:13 ` Kyuwon Cho 2026-11-24 6:32 ` Hangbin Liu 2026-11-24 8:42 ` Nikolay Aleksandrov 0 siblings, 2 replies; 4+ messages in thread From: Kyuwon Cho @ 2026-11-24 5:13 UTC (permalink / raw) To: netdev Cc: Jay Vosburgh, Hangbin Liu, Nikolay Aleksandrov, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel bond_open() adds the 8-byte lacpdu_mcast_addr to every slave of an 802.3ad bond with dev_mc_add(), which copies the slave's addr_len bytes. A slave with a 16-byte address, such as an ip6tnl device, makes it read past the array: 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) Commit c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet devices") rejects such a slave 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. A slave that is itself a bond can also change its type after it was enslaved, when a non-Ethernet device is enslaved to it. Check that an 802.3ad slave is an Ethernet device before the type handling, for every slave, and refuse NETDEV_PRE_TYPE_CHANGE for a slave of an 802.3ad bond, as team does for its ports. Other modes still allow the type change, as bond-eth-type-change.sh expects. 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> --- drivers/net/bonding/bond_main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 776afdb9df43..cf67104777d0 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); @@ -3992,6 +3993,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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4 1/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds 2026-11-24 5:13 ` [PATCH net-next v4 1/1] " Kyuwon Cho @ 2026-11-24 6:32 ` Hangbin Liu 2026-11-24 8:42 ` Nikolay Aleksandrov 1 sibling, 0 replies; 4+ messages in thread From: Hangbin Liu @ 2026-11-24 6:32 UTC (permalink / raw) To: Kyuwon Cho Cc: netdev, Jay Vosburgh, Nikolay Aleksandrov, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel On Tue, Nov 24, 2026 at 02:13:03PM +0900, Kyuwon Cho wrote: > bond_open() adds the 8-byte lacpdu_mcast_addr to every slave of an > 802.3ad bond with dev_mc_add(), which copies the slave's addr_len bytes. > A slave with a 16-byte address, such as an ip6tnl device, makes it read > past the array: > > 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) > > Commit c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet > devices") rejects such a slave 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. A slave that is itself a > bond can also change its type after it was enslaved, when a > non-Ethernet device is enslaved to it. > > Check that an 802.3ad slave is an Ethernet device before the type > handling, for every slave, and refuse NETDEV_PRE_TYPE_CHANGE for a > slave of an 802.3ad bond, as team does for its ports. Other modes still > allow the type change, as bond-eth-type-change.sh expects. > > 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> > --- > drivers/net/bonding/bond_main.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 776afdb9df43..cf67104777d0 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); > > @@ -3992,6 +3993,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 > The type change for other modes can be discussed later. The current change targeting this issue looks good to me. Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4 1/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds 2026-11-24 5:13 ` [PATCH net-next v4 1/1] " Kyuwon Cho 2026-11-24 6:32 ` Hangbin Liu @ 2026-11-24 8:42 ` Nikolay Aleksandrov 1 sibling, 0 replies; 4+ messages in thread From: Nikolay Aleksandrov @ 2026-11-24 8:42 UTC (permalink / raw) To: Kyuwon Cho, netdev Cc: Jay Vosburgh, Hangbin Liu, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel On 24/11/2026 07:13, Kyuwon Cho wrote: > bond_open() adds the 8-byte lacpdu_mcast_addr to every slave of an > 802.3ad bond with dev_mc_add(), which copies the slave's addr_len bytes. > A slave with a 16-byte address, such as an ip6tnl device, makes it read > past the array: > > 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) > > Commit c84fcb79e5db ("bonding: limit BOND_MODE_8023AD to Ethernet > devices") rejects such a slave 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. A slave that is itself a > bond can also change its type after it was enslaved, when a > non-Ethernet device is enslaved to it. > > Check that an 802.3ad slave is an Ethernet device before the type > handling, for every slave, and refuse NETDEV_PRE_TYPE_CHANGE for a > slave of an 802.3ad bond, as team does for its ports. Other modes still > allow the type change, as bond-eth-type-change.sh expects. > > 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> > --- LGTM, Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-24 8:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-24 5:13 [PATCH net-next v4 0/1] bonding: keep non-Ethernet slaves out of 802.3ad bonds Kyuwon Cho 2026-11-24 5:13 ` [PATCH net-next v4 1/1] " Kyuwon Cho 2026-11-24 6:32 ` Hangbin Liu 2026-11-24 8:42 ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®