From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796069440; b=pqzKAYlWKi9RK9N9Zs2xaRDdV5ne3pN2ttmbxV+qDdemypokOBZccZg+5Ech0tmQN8WX U7WlItGi4Pf3KVQCjOZEfF9xZXFHYP66WpZfgF9zN8t+upMdoKwq29k0ZJY/wpnJWzJrX bYeEWGFhuMjKXTxHmzffyKmf1xQIdn9HQpl+XsWvkXly4GGWWCgo+LUfL+yZ9ohJ/vN+B wztEuVv0OEYpJU1n2JHb1Qlmm2AA73DCoARI44SlLzKhp06QwQbaj0dg9T4nMQCBrcATF AnIkn90G4BYU7i9ku7rPRaTOep2zq/p3F7tJ3ciAPQHus1vJ9+e80JC4kYZd/cLgN/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796069440; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=aQah7BckDXorQ1iyAU4VKCaYhN5NcZbY1uWeM/x6n/I=; b=g8S9qQUlxqVZA0uBupLfk4PcuCABZP7tJD07TYOw+FoGDZ/kT9J8jWo0jupbFXVG2Z/V 7zYsbLyUAScZO6WzsFclo3OEOCcXJ1xO8+BodEeDTF11PYR3Ywc6uq5HAC2naxQv2VH2z ZSkQmkPUjcgYP+PG91xq9f3Kv6LhhDKxiGTThKKuSVVnJWvjn/7QWll6TtnBrfuPzT8xf bUkXkMBm5MOttw93Rb8wE00K4gCWYIBJumLAogAVZGVANhiSMmmIljuzuzwUU7B3++1MR ZJCGoO86nr6Hxca3p8s8WZ8SKkKd6xMe5eopeJz9bwtI9XncTI0zSmnrzBgZ/Z7oUWQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meAEgO1v; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10A58606A320; Mon, 30 Nov 2026 20:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meAEgO1v Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95CE81F0089A; Mon, 30 Nov 2026 20:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796069439; bh=aQah7BckDXorQ1iyAU4VKCaYhN5NcZbY1uWeM/x6n/I=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=meAEgO1vy7PswQ5l6RncaRR13WXZAUKyNphY3Z9mzzQaTf4gGALjo9T7X+6klMOaA Mw3kWoNjLiBS+9mbLTGsmR4Q8PoET6/I/acembvrjtX83yCZaaFg7sxaJSpWGKRD6j y65w0hC52mP6YHKQn/boXbyrWmaJ2l4xhMdhtQ3LoZw0mIKj5EIO7pD88czA7rqhaH tuh+WcIrPgv7vAw6z9YxB/xOuWiEPrdbPvdWV0HGWJDLuxj0xADoRadfUsc24NTAkR E+y7biZXjoU35IOV0LgR2UFvRgt2wM0pV33IGMED+PIERx1n/eD7+/QwSssFswRDQp vKWYg5zikylhg== Date: Mon, 30 Nov 2026 20:10:35 +0000 From: Simon Horman To: Baoli Zhang Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, jamie.iles@oss.qualcomm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] bonding: fix use-after-free in slave_kobj_release() Message-ID: <20261130201035.GK804035@horms.kernel.org> References: <20261120130814.2131659-1-baoli.zhang@linux.intel.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261120130814.2131659-1-baoli.zhang@linux.intel.com> 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 Reviewed-by: Simon Horman