Article View: linux.kernel.netdev
Article #24152Re: [PATCH net-next] bonding: undo enslave state when XDP setup fails
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 13:01
Date: Sun, 29 Nov 2026 13:01
225 lines
16549 bytes
16549 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The second bond_slave_ns_maddrs_del() that the patch adds at
err_close in bond_enslave() (drivers/net/bonding/bond_main.c:2402)…
- [Low] The patch fixes leaks visible to users after a failed
bond_enslave(): stale promiscuity/allmulti counts and synced uc/mc…
- [Low] The commit author is 'Hangbin Liu <hangbin.liu@linux.dev>', but
the only Signed-off-by is 'Hangbin Liu <liuhangbin@kylinos.cn>'.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the
bond_enslave() error labels the patch extends still do not undo…
--
bonding: undo enslave state when XDP setup fails
This patch adds undo steps at err_dec_slave_cnt in bond_enslave() for
the ns maddrs, promiscuity, allmulti and synced addresses when one of
the XDP checks fails. It also adds a second bond_slave_ns_maddrs_del()
at err_close, meant for the case where the new slave was selected active
and is then demoted on the error path.
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
[Severity: Low]
This isn't a bug, but the author address is hangbin.liu@linux.dev and
the only Signed-off-by uses liuhangbin@kylinos.cn. checkpatch reports a
From:/Signed-off-by: email address mismatch. Could the two addresses be
made to match?
[Severity: Low]
Should this have Fixes: tags?
The promisc/allmulti/address leak on the XDP failure paths appears to
come from 9e2ee5c7e7c3 ("net, bonding: Add XDP support to the bonding
driver"). The ns maddr leak appears to come from 8eb36164d1a6
("bonding: add ns target multicast address to slave device").
The earlier related fix a978095699641d ("bonding: fix slave_cnt leak on
XDP enslave failure") carries Fixes: 9e2ee5c7e7c3.
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 776afdb9df43e..a3daf005b444d 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2364,7 +2364,16 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>
> /* Undo stages on error */
> err_dec_slave_cnt:
> + bond_slave_ns_maddrs_del(bond, new_slave);
> WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1);
> + if (!bond_uses_primary(bond)) {
> + if (bond_dev->flags & IFF_PROMISC)
> + dev_set_promiscuity(slave_dev, -1);
> + if (bond_dev->flags & IFF_ALLMULTI)
> + dev_set_allmulti(slave_dev, -1);
> + if (bond_dev->flags & IFF_UP)
> + bond_hw_addr_flush(bond_dev, slave_dev);
> + }
[Severity: High]
This is a pre-existing issue and this patch did not introduce it. The
error labels being extended here still skip several steps that
__bond_release_one() performs.
In 802.3ad mode, bond_enslave() calls bond_3ad_bind_slave(new_slave).
No error label calls bond_3ad_unbind_slave(). Only __bond_release_one()
does:
drivers/net/bonding/bond_main.c:__bond_release_one() {
...
if (BOND_MODE(bond) == BOND_MODE_8023AD)
bond_3ad_unbind_slave(slave);
...
}
bond_3ad_state_machine_handler() runs from ad_work under mode_lock and
rcu_read_lock, not RTNL. That means it can run after the slave is linked
and before the XDP or sysfs failure.
The newly bound port is not AD_PORT_SELECTED, so ad_port_selection_logic()
picks it up. With no matching LAG it takes the first free aggregator,
which can belong to another existing slave:
drivers/net/bonding/bond_3ad.c:ad_port_selection_logic() {
...
free_aggregator->lag_ports = port;
free_aggregator->num_of_ports++;
rcu_assign_pointer(port->aggregator, free_aggregator);
...
}
The error path then unlinks the slave, and bond_free_slave() calls
kfree(SLAVE_AD_INFO(slave)).
Can the other slave's aggregator->lag_ports then point to freed memory?
Later ticks would read it through __agg_active_ports() and
ad_agg_selection_logic(), and write through __set_agg_ports_ready().
__bond_xdp_check() allows 802.3ad with XDP, so the XDP failure labels
can reach this. The bond_sysfs_slave_add() failure path can reach it
too.
Separately, netdev_compute_master_upper_features() and bond_set_carrier()
ran with the failing slave counted:
WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
netdev_compute_master_upper_features(bond->dev, true);
bond_set_carrier(bond);
They do not run again after slave_cnt is decremented and the slave is
unlinked.
Could the bond keep carrier on, or keep stale features, with zero
slaves? One example is the first slave of a bond that already has an XDP
program and that fails the XDP checks.
Also, in TLB/ALB modes, the sysfs failure path never undoes
bond_alb_init_slave() with bond_alb_deinit_slave().
>
> err_sysfs_del:
> bond_sysfs_slave_del(new_slave);
> @@ -2390,6 +2399,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
> slave_disable_netpoll(new_slave);
>
> err_close:
> + bond_slave_ns_maddrs_del(bond, new_slave);
[Severity: High]
Is there a matching add for this second bond_slave_ns_maddrs_del() on any
path?
The commit message says:
If the new slave was selected active before the failure, err_detach
demotes it via bond_change_active_slave(NULL) and bond_hw_addr_swap()
re-adds them after the first removal
In bond_change_active_slave(), the swap runs before the old active slave
is flagged inactive:
drivers/net/bonding/bond_main.c:bond_change_active_slave() {
...
if (bond_uses_primary(bond))
bond_hw_addr_swap(bond, new_active, old_active);
...
if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
if (old_active)
bond_set_slave_inactive_flags(old_active,
BOND_SLAVE_NOTIFY_NOW);
...
}
So when bond_hw_addr_swap() calls bond_slave_ns_maddrs_add(bond,
old_active), the slave is still active and the gate rejects it:
drivers/net/bonding/bond_options.c:slave_can_set_ns_maddr() {
return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
!bond_is_active_slave(slave) &&
slave->dev->flags & IFF_MULTICAST;
}
The re-add therefore does nothing. By the time err_close runs, though,
the slave is flagged backup. This del then passes the gate and calls
dev_mc_del() for every NS target MAC.
In active-backup mode with arp_validate and ns_ip6_target set, each of
these cases seems to end at net -1:
- The new slave was selected active. The add in bond_enslave() is +1.
The del of new_active in bond_hw_addr_swap() is -1. The
err_dec_slave_cnt del is skipped (slave active). The err_detach
re-add is skipped (still active). The err_close del is -1. This case
was balanced before the patch.
- The new slave stayed backup. The add is +1, the err_dec_slave_cnt
del is -1 and the err_close del is -1.
- Older failure paths reach err_close after
bond_set_slave_inactive_flags() in the BOND_MODE_ACTIVEBACKUP case.
These are the netpoll enable, netdev_rx_handler_register(),
bond_master_upper_dev_link() and bond_sysfs_slave_add() failures.
They now run a del even though bond_slave_ns_maddrs_add() never ran.
The commit message also says:
on every other path it is a harmless no-op, since deleting an address
that is not on the mc list does nothing.
dev_mc_del() ends up in __hw_addr_del_entry(), which decrements
ha->refcount without checking who owns the reference, and frees the
entry when it reaches zero.
Another owner may hold the solicited-node MAC 33:33:ff:xx:xx:xx on the
slave, for example a packet socket with PACKET_MR_MULTICAST, or a VLAN
or macvlan upper. Can this del drop that owner's reference and remove
the hardware filter? That owner's later delete would then fail with
-ENOENT.
The err_dec_slave_cnt del already undoes the add on the XDP failure
paths. Could the err_close call be dropped?
Related, and not introduced by this patch: because of the same ordering
in bond_change_active_slave(), a slave demoted on an ordinary failover
also becomes a backup without NS maddrs.
> if (!netif_is_bond_master(slave_dev))
> slave_dev->priv_flags &= ~IFF_BONDING;
> dev_close(slave_dev);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-bond_xdp_rollback-v1-1-35dddaa337ba%40kylinos.cn
Technical Details
Message-ID:
<179595731839.3146.9352124638865415714@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373500-linux-kernel-netdev=dewy.ruReferences:
<20261125-bond_xdp_rollback-v1-1-35dddaa337ba@kylinos.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373500-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] bonding: undo enslave state when XDP setup fails Date: Sun, 29 Nov 2026 13:01:58 +0000 Organization: Usenet Network Message-ID: <179595731839.3146.9352124638865415714@kernel.org> References: <20261125-bond_xdp_rollback-v1-1-35dddaa337ba@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1172115"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:bUbeqNAJWOXZCJd16JKjxv6aUA8= sha256:+5VW6YezVrw77Uw5i4D4PBH9nJEjgot+fLFy5K/m49M= sha1:Xcovyc3IoKRZDZUNc5gwb975mBk= sha256:likRACp1i3hlhBXU1MY/b4pp2wPpeYpuPBs0gEEUf3w= 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 27B1A125F98; Sun, 29 Nov 2026 16:02:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 089SRmJQTeo2; Sun, 29 Nov 2026 16:02:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373500-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id D3ACC125F96; Sun, 29 Nov 2026 16:02:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id AF67C251B2; Sun, 29 Nov 2026 13:02:01 +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=1795957321; b=GPIpcl4KP4Tzbl7WPhJCMdBPCjRlOt7Ny5vggw0ncMsq2yB2kX7T3Q2HYHJBeh8brNdA P4MesdB4A7b54hpGdQYlpq/R4oQokdhfO7j3KORNoep9qk9MvpsgmoyA9k+IqdHpn7FbI M7JuyD1kVzJnt2k89fRLoR44thvME64SKo8aeUAj0kck4ScbSGMlaryn/sCH9puou/+wh 2iufi6I4PPlZrQ7PvnIdeInD62dhM6YuAqXi7WX4H2PEf7LZ58t2uLM5M6iYjtqmuXkbX Vk+ice2/NsSZjQh0RASN4JOJyb+L8FGRPFY5QeaT21EA55oKycIPROlEqooSSQKoFrQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795957321; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=I7N1H8nRIUPfsq5YllUOQogPmWxLZ9/ie/GNDxTEQv0=; b=jUVtE5GMXxuBpO0/voseRWscXtYBX0p+wpE58NM1CCavxgI55IJKUGhuj8slgDP/VrqG vz4m9LxskRqSn4smjS7oKxr558tZEEK8ewltNSHT8KMYo5M1B2ZDtlZCok706AtaFvJmR 9PDKXp/pBmMGupIVQlRwGaYQoVek6r6VMHKDXnDzxZV4tW8f7r8vCPmR3zb71TeHnIr/0 KGfPtbd37Oe06uCFXf9wWTQmH6O1SutQFUl/VO6aM5CWalTbVEIskJ/dFPAMMkjqhxb1h 2wc2GstY1GfPP0O4VRJusovk5t/GoV+Aj/GTGdo5L6MG9/vm/5c0b9praHZMKJVd6Qw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Zea0cnYi; 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 E597F606A338; Sun, 29 Nov 2026 13:02:00 +0000 (UTC) X-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=Zea0cnYi X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795957320; b=dZuneDYLfUdzu3yzXBJVcxDo0SopFR75UHc8cjmytYTv5Z5MctbW3JII1PD60Y9N1K/n i6c12NR2W5ydxltMzgZOCUrKogPfQHSaU2Lj1i0uxVOdxj2A84GZ8cpqCvBsqNzmfv8X3 ARt7bmnXjKhIY9+4qbviprmX2ZwJ0y9GtO8SCU/cUL8nepbD9WdKeWpqDMaoASOuzEbRG oyOSTyP3eEeD1TPSW98yAoOyqxvPAgYznqFdPkD9Vrk7mbhC4hlW+9yCtSSZmffrIuEab WVpqM9rdamnHhZT1N8P2mOHmkCntSE87JxvoIU0EsmoOqUztT2/I8d2bfcAEWbjFQzw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795957320; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=I7N1H8nRIUPfsq5YllUOQogPmWxLZ9/ie/GNDxTEQv0=; b=mQO1JDrdawuxNqS190WMGQ5dIaHr/UGfCxFW7LXR/mbZFZt9NdRCesd1MXZrr1uJ8EiE iDs9AOO9Kgrx6ml8qJBujRDoqWb3FkN7L8XvUJ23FCDG6Jt0ccej98b0tZgyxK4tjeHkS UzxWiQVA69S37PMMlr4J+OJ5xOEMrTnWnEb/OqwogWb2LgEELB1ZxRZm+0Wm6JdG3rnVs 8P5mO6L7aFggKIUFd/MirfKTLZFk4DfR/1JMnfI4PEIUPH17GGxKKGAySRFr9qb0gKbHj OSnECr3fgv1uwYHJn26E6Ril6cEDqWM6LqL5duYQuzzXDV2EdEn/oA/5ZuuaL55St/Q== X-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=Zea0cnYi; arc=none smtp.remote-ip=100.103.45.18 X-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 12362606A323; Sun, 29 Nov 2026 13:01:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD08B1F00896; Sun, 29 Nov 2026 13:01:58 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795957319; bh=I7N1H8nRIUPfsq5YllUOQogPmWxLZ9/ie/GNDxTEQv0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Zea0cnYi+0Ov3v4++4YhY5SL13loU5lKbYNL9VRK7gt2EoBlx6yMLuVXdaKYqP7oN qJHKyjSqwg4CGq7H8FeW1pf59JP/SFfFWaiRMprHWpaQwk+/HQ8jZrl+kIAtz+dRJg NbjxJ3YiL7QYUXYjDCRPkcODhONlFwYdw30tMv+atG/8Y+/XK8eBSEFKDHayQSJyWN jDWgPVULyF4Bwqvv2oRkDqH1PIHhvwE9h3W23VkrnUw+vwJrSu33mv04Bwvqppo7bf wQdsXGYVTAp5Ufe5XFDZ/Omwe83/WTbXCLyS/VnTWRIn6PKjHCC1iSTcPqAq+tmJTm K8J3+2NpAariA== X-Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org X-In-Reply-To: <20261125-bond_xdp_rollback-v1-1-35dddaa337ba@kylinos.cn> X-sashiko-severity: High 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