From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796268896; b=YPjk2KqeVfy3ipp6GM21+Fi9vKArNjD0pq3lzlkUeik1DpdbWwLUnj6LbOGi112Uf1Sd 0PLOKjeQC6w4xfhdt15BOI0vhE3iUG88TRn8wXzF33Umb8KJcYTEN61j96MNY5YXK2VzJ pcLjDiRcHxjmui1VeLZgof99NGyXlf9DE1YBA9/wxwNdhmFaatOq+XRP6qnRjiO2UBt/T naFqNyETCei0WNKSHBoFeiY3UCPVwj8hkTSriKrdWkgpq8rIY1M9HsOkTgr1OSwWjDnrY 3TPBI2TSs8+dgmz5JKSldP/7HHH68+pOpYraTv5QBMm+CskCDZm5+9adRFzaj1pOnnA== 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=3togRePbJB3JlRhNf6OS+TmMF+He/T3HQoHz9gwU2yEyxiVFLlPtXUEqZo85EyLx1c+h zd6EP8nujgkLhCfkCd72QZLjOG4nCI7lEzBpHGkuavOQy5b/1xDYW4ZJMesgb+NQOau1r PhoDZUoZv0Z9zO0nefhfUblOfNjwmCh08SIXHZowQrtGn1uUbZ06mxMlYDS8O8dP793s5 mHeFENoxjrV0SVP59bk6YfzSE9TVVvoBbbJ8Ug/TWlZh5TwMKKAItbVDoEbGJb949AJB2 A1zI/sh2QJwSghF1Yc9dBvGIe9rUQrsqclXm7gl0eMjPSgzOzilASMAtbalBtzwKqRw== 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=91.218.175.225 Received: from mta0.migadu.com (out-225.mta0.migadu.com [91.218.175.225]) (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 0D231606A32C for ; Thu, 3 Dec 2026 03:34:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0D231606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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-Envelope-To: linux-kernel@vger.kernel.org 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: linux-kernel@vger.kernel.org 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 Date: Thu, 3 Dec 2026 11:34:41 +0800 From: Hangbin Liu To: willemb@google.com Cc: Jay Vosburgh , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails Message-ID: References: <20261124-bond_fail_over_mac-v1-1-9caee319331f@kylinos.cn> X-Mailing-List: linux-kernel@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Willem, On Wed, Dec 02, 2026 at 09:02:01PM -0500, willemb@google.com wrote: > Hangbin Liu wrote: > > From: Hangbin Liu > > > 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 > > 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