🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Baoli Zhang Fri, 20 Nov 2026 13:08
[PATCH net] bonding: fix use-after-free in slave_kobj_release()
#19816
Author: Baoli Zhang
Date: Fri, 20 Nov 2026 13:08
52 lines
10760 bytes
slave_kobj_release() dereferences slave->bond to check for 802.3ad mode
before freeing ad_info. The slave kobject's parent is the slave device,
not the bond, so the bond may already be gone when the release runs.

Normally the last reference is put while the bond is still alive, but
with CONFIG_DEBUG_KOBJECT_RELEASE the release is deferred and the bond
can be freed first:

  BUG: KASAN: slab-use-after-free in slave_kobj_release+0xe8/0x100 [bonding]
  Read of size 4 at addr ffff888112c99118 by task kworker/9:1/60681
  Workqueue: events kobject_delayed_cleanup
  ...
  Freed by task 60681:
   kvfree+0x31/0x40
   netdev_release+0x8b/0xc0
   device_release+0xdf/0x2a0
   kobject_delayed_cleanup+0x148/0x520

ad_info is only allocated in 802.3ad mode and is NULL otherwise, since
the slave is allocated with kzalloc(), and the mode cannot be changed
while the bond has slaves. Drop the mode check and free ad_info
unconditionally.

Fixes: b9ad3e9f5a7a ("bonding: wait for sysfs kobject destruction before freeing struct slave")
Signed-off-by: Baoli Zhang <baoli.zhang@linux.intel.com>
---
 drivers/net/bonding/bond_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a1c156c145b2d..0ec5bc838b86e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1732,11 +1732,10 @@ static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave)
 static void slave_kobj_release(struct kobject *kobj)
 {
 	struct slave *slave = to_slave(kobj);
-	struct bonding *bond = bond_get_bond_by_slave(slave);
 
 	cancel_delayed_work_sync(&slave->notify_work);
-	if (BOND_MODE(bond) == BOND_MODE_8023AD)
-		kfree(SLAVE_AD_INFO(slave));
+	/* ad_info is only allocated in 802.3ad mode, NULL otherwise */
+	kfree(SLAVE_AD_INFO(slave));
 
 	kfree(slave);
 }

base-commit: bc4c8c146447f71534e80db39c2d1149c6af5fd6
-- 
2.43.0
Re: [PATCH net] bonding: fix use-after-free in slave_kobj_release()
#23409
Author: Jiayuan Chen
Date: Fri, 27 Nov 2026 08:30
4 lines
8293 bytes

Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Re: [PATCH net] bonding: fix use-after-free in slave_kobj_release()
#24778
Author: Simon Horman
Date: Mon, 30 Nov 2026 20:10
29 lines
8856 bytes
On Fri, Nov 20, 2026 at 09:08:14PM +0800, Baoli Zhang wrote:
> slave_kobj_release() dereferences slave->bond to check for 802.3ad mode
> before freeing ad_info. The slave kobject's parent is the slave device,
> not the bond, so the bond may already be gone when the release runs.
> 
> Normally the last reference is put while the bond is still alive, but
> with CONFIG_DEBUG_KOBJECT_RELEASE the release is deferred and the bond
> can be freed first:
> 
>   BUG: KASAN: slab-use-after-free in slave_kobj_release+0xe8/0x100 [bonding]
>   Read of size 4 at addr ffff888112c99118 by task kworker/9:1/60681
>   Workqueue: events kobject_delayed_cleanup
>   ...
>   Freed by task 60681:
>    kvfree+0x31/0x40
>    netdev_release+0x8b/0xc0
>    device_release+0xdf/0x2a0
>    kobject_delayed_cleanup+0x148/0x520
> 
> ad_info is only allocated in 802.3ad mode and is NULL otherwise, since
> the slave is allocated with kzalloc(), and the mode cannot be changed
> while the bond has slaves. Drop the mode check and free ad_info
> unconditionally.
> 
> Fixes: b9ad3e9f5a7a ("bonding: wait for sysfs kobject destruction before freeing struct slave")
> Signed-off-by: Baoli Zhang <baoli.zhang@linux.intel.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads