Article View: linux.kernel.netdev
Article #16982Re: [PATCH] bonding: unbind 802.3ad slaves on enslave failure
From: Hangbin Liu
Date: Mon, 16 Nov 2026 07:34
Date: Mon, 16 Nov 2026 07:34
67 lines
11009 bytes
11009 bytes
Hi Jiapeng,
On Fri, Nov 13, 2026 at 09:04:40PM +0800, Lin Jiapeng wrote:
> From: Lin Jiapeng <jiapenglin@tencent.com>
>
> The 802.3ad enslave path binds a slave to an aggregator before publishing
> it in the bond's slave list. This lets the periodic state machine select
> the port and attach it to a LAG while enslavement is in progress.
>
> If a later step fails, the rollback removes the slave and frees its
> ad_slave_info without unbinding its port. A port selected in the meantime
> can remain linked from another live slave's aggregator, so later LAG
> processing accesses freed memory. A test-only kretprobe forces
> bond_sysfs_slave_add() to return -ENOMEM, after which KASAN reports:
> BUG: KASAN: slab-use-after-free in ad_agg_selection_logic+0x1a0d/0x1fa0
> Read of size 1 at addr ff11000109be946e by task kworker/u16:0/13
> Freed by task 110:
> kasan_save_stack+0x30/0x50
> kasan_save_track+0x14/0x30
> kasan_save_free_info+0x3b/0x70
> __kasan_slab_free+0x47/0x70
> kfree+0x1b3/0x550
> slave_kobj_release+0xb6/0xd0
> kobject_put+0x17e/0x300
> bond_enslave+0x1acc/0x5090
>
> Call bond_3ad_unbind_slave() in the common rollback for published slaves
> before unlinking the slave from the bond. This detaches the port under
> mode_lock and preserves the invalidate-drain-free ordering used by normal
> release. Successful enslavement and earlier unpublished failures are
> unchanged.
>
> Fixes: 07699f9a7c8d ("bonding: add sysfs /slave dir for bond slave devices.")
> Reported-by: TencentOS Corvus AI <corvus@tencent.com>
> Signed-off-by: Lin Jiapeng <jiapenglin@tencent.com>
> ---
> drivers/net/bonding/bond_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index e9f5e753f677..60cc9a6a4fc7 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2355,6 +2355,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
> bond_sysfs_slave_del(new_slave);
>
> err_upper_unlink:
> + if (BOND_MODE(bond) == BOND_MODE_8023AD)
> + bond_3ad_unbind_slave(new_slave);
> bond_upper_dev_unlink(bond, new_slave);
>
> err_unregister:
> --
> 2.55.0
>
Thanks for your fix. I’m also working on correcting some error rollback issues
in `bond_enslave`, including the 3ad unbind problem. My patch still needs
further adjustments[1].
Just FYI, I’ll leave it up to the maintainer to decide whether to apply
your fix first.
[1] https://lore.kernel.org/all/20261113-bond_enslave_restruct-v1-0-364c549e78db@kylinos.cn/
Thanks
Hangbin
Technical Details
Message-ID:
<avqyGXhRkA0gfoEr@fedora>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364095-linux-kernel-netdev=dewy.ruReferences:
<20261113130454.63032-1-ljp1205831794@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364095-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] bonding: unbind 802.3ad slaves on enslave failure Date: Mon, 16 Nov 2026 15:34:49 +0800 Organization: Usenet Network Message-ID: <avqyGXhRkA0gfoEr@fedora> References: <20261113130454.63032-1-ljp1205831794@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2003378"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:WDfMxgQI4OIK4bQ1DeAk6DcSbnY= sha256:JuXmh6oDEzTpCuRrC4R5VDVt/KkzQHFEvzZ/8xO/GME= sha1:Pvyo4wvTBwKaD1Jvh/9nV2TMnGo= sha256:eXSJG2XiguKctBcX1Q7czPdPcql5sppPfSElP90deGo= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 4E720114B4D; Mon, 16 Nov 2026 10:35:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ah32ock8SR1S; Mon, 16 Nov 2026 10:35:28 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364095-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id E924F114B35; Mon, 16 Nov 2026 10:35:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 834C7266C5; Mon, 16 Nov 2026 07:35:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794814514; b=rPvNNMuCiKA235bowrLkbVXTS5eW7caoiO64G0wUY7WWDqal6l0ZINara7LkgmcZOhRg 0YhzvwdyvDWxebR+Ze6mAKO6YWsfVlHv15R8af5j9qi+AJtcPjp6comFu2wlCQ3hEc2n9 saAonRIoznU6Madk3hd4iShyd0i+jDImAs6Czbocc4PRXahu2i03iBdkll5Q/5AqcI+vB LXskqnR2z1SqSMLJsmRFew/z2ZPKv2aYMQy6XIp2ea1BAk51z6s/bGGMpHoE02UhgIjOi ZxnLzhijW5WixlsMezFRrp2lHQX13d6mjpSLwL7cJ2VjRdpfERW52LATt+fw57EMaVA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794814514; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=fIDdNcF/l0x9lZp8RfumuNlHiHkBHNTTSBewvQAJ4vY=; b=ruW2PC+b4LXXL/rQ07e0M+hfrRpEA9sT8VFeeSSDvkH37Cdt1RUAVFxokUCdj75ZJ7iO KW7b6D6atCoJEvRkM1iFnflIXx/9cb5QK2+gOAavLIp93xGHZ77L8WLLx9UWSipGBywXy mnvMOHch/uey/+qaZSSSO7lSgZtWW/klYaeKKcUtQouxA93xhULYdeM4VtmafFpWOKFFV MyUmBNThYOuxYAN/puKY6bTn0Y5qT8AVaJdm8PkAffLPSdeNVOmKvQZcGuNLB4Qt5xZIC UnWN0gjdSzeJGIdxr6vqRiQ6d7UFtLLfWyLverY9clbjcP65+krIDf+5kswKC3onozQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e5wR6+lB; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91F54606A337; Mon, 16 Nov 2026 07:35:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e5wR6+lB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.25 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794814513; b=vuEQzCV2ZqmfAynFatshATDxqhQoNNGEJTi+wHoO5cys7iqTg/0jRxgss9eHW2Bv25kW E2Sq56l616iyeJlePu/ppM5SrfR5WTepEROnyL1K8H9BND7r3IakCan0DFzZzg7aU7Q9l ejcyPNpz+qz0rVmQaqLuSBy2PDqd9JLOSfKepkCNalhQ+zR3cTve82MLxthctm6ccPX1V 1Y+QZ2oD996awEtkb7yAZc04c2bXWjSr/CBE/EK/SrIputYh11ddnJkb9o71fr0RDbVPm TapvcyQtrA1yiw6Qzg9ENJNIbJtzM3c6JasBzdHCtTr0q7Lgu9mSlV1DdeO5Hp+ur5Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794814513; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=fIDdNcF/l0x9lZp8RfumuNlHiHkBHNTTSBewvQAJ4vY=; b=ScYxV0+zCrLrlyorCCMA8t93ziITGe47AmPBMe7RTaS3AiSNF5Vq/1Qr307z4RA0I0/O OsIkAx60pYMlBIPvrcqtzAvyGN/nQx7DXyVJGh+pBk/BE3mMDa1N55Z7ABO0wZdp/HkMt 5rxlxuMaAmie2Kt83Wvi2QwV2VD9OZdhF8gVKKq6n3mrMDSlPpCAk53OaAAcvtcgCNcWQ jhAIsWWo23CqhUUz5M3PaxwhyI2cTzjtHHp9KzjA+tAhDGdQtqbKl75B1DM5j7Vt5/JXB VTdcxNCV68UoaLBo395GAnYtoVC4x2zXSyCSWZRy/72kPx+vqKw+eUGL5lEPm+qUvFw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=e5wR6+lB; arc=none smtp.remote-ip=95.215.58.25 X-Received: from mta1.migadu.com (out-25.mta1.migadu.com [95.215.58.25]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4DFD606A32A for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 07:35:12 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E4DFD606A32A X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=x4W9yp3gYy0iqIhiaZihhZVq/EH24yiSsMyRtu3ztFY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794814510; v=1; x=1795419310; b=e5wR6+lBOsAwBtaBKgbi5r01C59pveEpoxWK4HNiqUeaWkqAQWOU89MNWjqrz/quCBAMKdOA DRNkRWrPLPx3DoKCw0ERMs7I8ufHdahhqCyOQYzkg4Y3F19R+nqyIsOYyJMsxfg87205XMK1rWq PmkZDdr7h/1xZ4FvH2JHJT80= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta11.migadu.com with ESMTPS id 1092aa451d9b8fb9; Mon, 16 Nov 2026 07:35:09 +0000 X-Mizu-Trace-ID: 1092aa451d9b8fb9 X-Migadu-Flow: FLOW_OUT X-Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, sfeldma@cumulusnetworks.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lin Jiapeng <jiapenglin@tencent.com>, TencentOS Corvus AI <corvus@tencent.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261113130454.63032-1-ljp1205831794@gmail.com>