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 <baol…@linux.intel.com>
Reviewed-by: Simon Horman <hor…@kernel.org>