🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26124

Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails

#26124
From: Hangbin Liu
Date: Thu, 03 Dec 2026 03:34
81 lines
11776 bytes
Hi Willem,
On Wed, Dec 02, 2026 at 09:02:01PM -0500, willemb@google.com wrote:
> Hangbin Liu wrote:
> > From: Hangbin Liu <liuhangbin@kylinos.cn>
> 
> > bond_enslave() can change bond->params.fail_over_mac as a side
> > effect: when the first slave cannot set its own MAC address and the
> > bond is in active-backup mode, fail_over_mac is forced to "active" so
> > bonding never writes the slave MAC. If enslave fails later, the
> > forced value stays behind, silently changing a user-configured
> > option after a failed operation and affecting subsequent failover
> > behaviour.
> 
> > Snapshot fail_over_mac on entry and restore it on the error path.
> 
> > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
> 
>     When respinning, please fold the discovery context and the WireGuard +
> XDP
>     reproducer from your reply to Paolo into the commit message (per sinfo),
>     and consider adding:
> 
>       Fixes: 3915c1e8634a ("bonding: Add "follow" option to fail_over_mac")
> 
>     Also if targeting net-next.

Sometimes I'm a little confused whether the small/corner fix should be target
to net or next. Usually we post all fix to net. But last time I was told
to post none critical, small fix to net-next.

> 
> > ---
> >   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 9249a79a168e..3817c82e89e2 100644
> > --- a/drivers/net/bonding/bond_main.c
> > +++ b/drivers/net/bonding/bond_main.c
> > @@ -1890,6 +1890,7 @@ int bond_enslave(struct net_device *bond_dev,
> > struct net_device *slave_dev,
> >   {
> >   	struct bonding *bond = netdev_priv(bond_dev);
> >   	const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
> > +	int orig_fail_over_mac = bond->params.fail_over_mac;
> >   	struct slave *new_slave = NULL, *prev_slave;
> >   	struct sockaddr_storage ss;
> >   	int res = 0, i;
> > @@ -2412,6 +2413,7 @@ int bond_enslave(struct net_device *bond_dev,
> > struct net_device *slave_dev,
> >   	kobject_put(&new_slave->kobj);
> 
> >   err_undo_flags:
> > +	bond->params.fail_over_mac = orig_fail_over_mac;
> 
>     Since commits 4dc5a40b3bc9 ("bonding: annotate data-races in sysfs and
>     procfs") and 317cefdcaacc ("bonding: no longer rely on RTNL in
>     bond_fill_info()"), bond->params.fail_over_mac is read without RTNL via
>     READ_ONCE() in bonding_show_fail_over_mac() (bond_sysfs.c:268),
>     bond_info_show_master() (bond_procfs.c:71), and bond_fill_info()
>     (bond_netlink.c:804), paired with WRITE_ONCE() in
>     bond_option_fail_over_mac_set() (bond_options.c:1587).
> 
>     Doing an unannotated plain store here — unconditionally on every failed
>     bond_enslave(), even when fail_over_mac did not change — introduces a
>     KCSAN data race against those lockless readers. Guard the restore and
>     use WRITE_ONCE():
> 
>         if (bond->params.fail_over_mac != orig_fail_over_mac)
>             WRITE_ONCE(bond->params.fail_over_mac, orig_fail_over_mac);
> 
>     (The pre-existing `bond->params.fail_over_mac = BOND_FOM_ACTIVE;` store
>     earlier in bond_enslave() at line 2018 is also missing WRITE_ONCE() and
>     is worth annotating in the same patch.)

Thanks, I will update with this change.

---
pw-bot: cr
Technical Details
Message-ID: <axDjUdZzsi5OisBe@fedora>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376259-linux-kernel-netdev=dewy.ru
References: <20261124-bond_fail_over_mac-v1-1-9caee319331f@kylinos.cn> <willemb.21a10875e7797@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376259-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave
 fails
Date: Thu, 3 Dec 2026 11:34:41 +0800
Organization: Usenet Network
Message-ID: <axDjUdZzsi5OisBe@fedora>
References: <20261124-bond_fail_over_mac-v1-1-9caee319331f@kylinos.cn>
 <willemb.21a10875e7797@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2132554"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:V/2oXnO6wNGmdF3buRB/AGgXFfg= sha256:ftYoLsaIM9yonUvpftANJaXkkZ89i/AFGVEMoUDlK00=
	sha1:4bEpaDmvuwfLULw+AciU9f5huek= sha256:5e6VWj+U7szunzEW+w+Ixkd6cOYvNm9hgPwsws93VhY=
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 A25FB117806; Thu,  3 Dec 2026 06:35:16 +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 tK29zGATx92Q;
	Thu,  3 Dec 2026 06:35:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376259-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 36E1A117800; Thu,  3 Dec 2026 06:34:58 +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 312F72A057; Thu,  3 Dec 2026 03:34:57 +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=1796268897;
	b=koNkHEz9xjrCRLGVTMzApsD8EnrGFcBrhx83ScEg+EcIyPm4COKDizJQ60D9oM6EBBzj
	 W95DrHAncZaJ4OA+rt5SEecjPCHoXYHyWE4BhFJh6GPsOmxYVQ+k1h8cm/N8ttyyJhTgK
	 kaTjj/C/tS7Iev2s5UcLPr041VP31GcsigSoMPA/eLcmPVTZMO6Rze8HSssNs552/50ea
	 myFdM9HBg5DTdY51wjafBJUi9up5yV5MJ+GoiCdsLRrP7NGejhjVlYms0Fmnn3S524WIY
	 EEFCzUzpofcusrtQB5jZMmUZZFFJ6sVSJxNdlk4B9hWBljTWYqnFJm23dkz6VaZp8hA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796268897;
	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=HXatSNPfG7AkOSCQIZ0APDuzBEHbPnMuTM+8s9+4jSQ=;
	b=UlA3bZQMmUbz6tNWYNUzbFyU0rH+iHgSsOcO+cd5m4CmlEb4a7arLKYWzoPu/zWFlWpX
	 gCoNPGM3ukesMxPx1KjSp8vILpub4lXTVmtjLZNjIwoH3uCGiSVQSmOIi8o9Fh5ARA0QB
	 AtC++eoxcZB/R4xWLVzLVsjQYz/4FGQnfNmaypD65qcQVYCUMxikz/zJc2i9/3duT+QEy
	 sY/nnzprRUwC1gIAzShqiZwP3LRv+66N1jqAMl/gaqXQ+ZFDTlKJyf8kjzyMpB/MC6Deh
	 gidlSEUpts0+gWxyCnYO4dJq6E7Ai9jeSBYP9sB7u6eSr+EK1ESU2lm6jTRCe2Vp+PQ==
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=lHUgqFoG;
	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 EDA75606A336;
	Thu,  3 Dec 2026 03:34:56 +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=lHUgqFoG
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.126
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796268896;
	b=AaMrnG+/ltQvvCyGtDN/UIwepjD22FA+fVQ9+V2FbF3umb4/qMlq6ATptBWavbtiYLrP
	 edymA9mmUZsammrgHF5rxdd7FLXVVYzvYOTYeAZJFQ8osyuZ8AjB8YRmOHaozMufFej0v
	 4O98Y6ImU76YzpXvQ3OVz6ONbrTnkDxBj+oRquwVdSfZe4HLhDk1uVUl9ZyaWmc2vWOxQ
	 F8pYjXFxbLMAuc+0AQqDzgjv3v/srMKaPOTdfnooXoCq8LIrkd8yKqlVQc4nYqsiq1Cpg
	 JxExB7kanlmALztrOeaTNthIPtWLvqIrj0UR685o5FVTMYZOThB52BEwOoTRMfgqXUw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796268896;
	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=HXatSNPfG7AkOSCQIZ0APDuzBEHbPnMuTM+8s9+4jSQ=;
	b=yL9MxnwLjzRh19GaOnTkrvP3nmx6l2KEcfsxmdQDB9UMLXYaAZBBGKjcGkj5HTgS/HsW
	 D0KwWB895Fi3W+xo/8tW/65R+FbGyNQefZ7yHi5BnqRBzwKnacfXRCKz0vG8ZYDfWSFBM
	 CRzFQAHG1MZwxmo22Nxuc9tX4k/7YVQO1t9kdXCz1IoE8UdUUbFTUUJwV2kdXTNTI5Q25
	 ps6GRoNblZHWGuoWnDF+kTBAvRq8duQt7lF/LLzWj26FJ8L10Beu36MpFM1ESsPiGXnYn
	 WbG5x9cpgkfqTHNf9+GNvLET5DXXebiJ8xcAfd3QURfl4SfZbEs0vgrWPbXWH0n5IBg==
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=lHUgqFoG;
	arc=none smtp.remote-ip=95.215.58.126
X-Received: from mta1.migadu.com (out-126.mta1.migadu.com [95.215.58.126])
	(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 06C4D606A322
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 03:34:54 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06C4D606A322
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=mYbDEp2NP9rNoN6ul5HeQ/YLx+MHcYLmBEb5/hF2Qy4=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796268893; v=1; x=1796873693;
 b=lHUgqFoGEu9Aj0HIhf9h3UC2Z8kD+h7B5iLcD0ofHPqavaEtNiofkHbGOkQ5alh7nxGOd7dC
 WZhul6hAiBPECdkDK1qe7iMBATycKXo4UPj3gqTgvxyFtZ1ywJWFyLqTumXQLqQjvLcw38oZ33j
 qWQvfqDjjp3kWB4cFerQI5EY=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id a1b1833202612895;
	Thu, 03 Dec 2026 03:34:52 +0000
X-Mizu-Trace-ID: a1b1833202612895
X-Migadu-Flow: FLOW_OUT
X-Cc: Jay Vosburgh <jv@jvosburgh.net>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
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: <willemb.21a10875e7797@google.com>