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=1796488098; b=oEq4nuKh5y43ja6RFv1O3KnePUB8KV02G7EIOWIFQ3w2apY2y1M7yTHjrNu3Jai7g3uU NtGwtSLTjlAKkO4WW9Hy58sE6gKhaGoZouBGGb97yUJ5I1MegglvepqeKW2XM5YH18Fbx flIpXWwkY+phWkHTNeDXf3mXPOgABrXs4lA7W4O9fatucXnJI+0uBU26O2eXlAbZZ+lsb 6YBNsvEq1JdshNNo+4Zs5XZ1CBSg5iZUxKzM9kxVX4/PlQr2wVcVy5sSSCzhZ29NOAnTE +4bCpa78kFJm5dvr/1/tWKNAvtczARiF59eiKKCCtRgj9bqiWmiox+RX1vjshcZruag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796488098; 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=jEhtYZUfnxdvVrfvasPHK5aoaJlg5RbXI6ErboNeG3g=; b=4SJKoT55iZuyOIZfQZvtfcRZQVfhWgfo7zWNJBd+IfrXwYXuABroBSUqBiAL1/q4P9fS fj2PEfsWVW3mGpmSdQIIoSqeEZigEKaOSGg4S5lw2VkNsIkebHak4nKQrMqfNuehkJy+N xbSFwM4QhKYGWQJ1fksfvjpALfhVVdX2eJA1bBmixEyt27uIto9659xYPe1ISS2DBZUaN ydg7VC4oDTXcop5r7Xf+jLgHkvMfHqrN9UF8YmdipvML3JPR89ybT8jpD0QRmZmmI+low U1bTJ349Xdsp+xhBYfyLhqvulEyqMvCLNIKfWFNTCdUap0KDYVUyBhEkdbxLsH51M/A== 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=PwSKScTm; 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 9BE01606A33E; Sat, 5 Dec 2026 16:28:18 +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=PwSKScTm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C281F0092B; Sat, 5 Dec 2026 16:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796488098; bh=jEhtYZUfnxdvVrfvasPHK5aoaJlg5RbXI6ErboNeG3g=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PwSKScTmXSmQ11xHXELfIknFxUqUwQAr6bIjst3GkxD30hzyeJbcS66eFS+xfb17F nsScj812HHf4xe1XUjJkRlmyswPmpBsBkPN5At5ctIKIW6iVvFzoYSH3xzpDZgy2ne zDM7bJMIAyybaaKAqkRgvV8HwdJSql6hMXu5uXUHxYDsK8fVCcZ8hwbYz+2cjsnBD+ lKOSdiOldX9hruMbr1F3anQZpy5Rog/mtz9leiOCgNaQuc5tkncBWRwwFmFkgBAr8r 3vmLbFfovDnYqgMrESQEv3NFFQTe05b55fYEiRMAS44wfalmlVjSeKm85p9LF4OF4L ++EEcjRN8NDcQ== Subject: Re: [PATCH net-next v6 5/7] net: add dev_addr_set_sync() for driver address updates From: netdev-bot+sashiko@kernel.org To: satishkh@cisco.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebaddel@cisco.com, aradhana@cisco.com, rfaucett@cisco.com, sdf@fomichev.me Date: Sat, 05 Dec 2026 16:28:17 +0000 Message-ID: <179648809711.3146.13052498684450880211@kernel.org> In-Reply-To: <20261204-b4-enic-sriov-v2-vf-receive-control-v6-5-ca38950bbe07@cisco.com> References: <20261204-b4-enic-sriov-v2-vf-receive-control-v6-5-ca38950bbe07@cisco.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The concern: dev_addr_set_sync() is exported with EXPORT_SYMBOL_GPL from net/core/dev_api.c and declared in… - [Low] The concern: dev_addr_set_sync() requires RTNL held and the device instance lock not held. - [Low] The concern: dev_addr_set_sync() changes dev->dev_addr and the dev->dev_addrs rbtree under RTNL and dev_addr_sem only, and it forbids… -- net: add dev_addr_set_sync() for driver address updates This adds an exported helper, dev_addr_set_sync(), for drivers that publish a new primary device address while holding RTNL. It takes dev_addr_sem for writing around dev_addr_set(), so the update is serialized with the sysfs and SIOCGIFHWADDR readers. It also asserts that the caller holds neither dev_addr_sem nor the device instance lock. > diff --git a/net/core/dev_api.c b/net/core/dev_api.c > index 437947dd08ed5..081e9cb063b69 100644 > --- a/net/core/dev_api.c > +++ b/net/core/dev_api.c > @@ -85,6 +85,27 @@ void dev_set_group(struct net_device *dev, int new_group) > netdev_unlock_ops(dev); > } > > +/** > + * dev_addr_set_sync() - publish a driver-selected device address > + * @dev: device whose address is being updated > + * @addr: new address, with dev->addr_len bytes > + * > + * Serialize the update with sysfs and SIOCGIFHWADDR readers. > + * The caller holds RTNL and must hold neither dev_addr_sem nor the > + * device instance lock. > + */ > +void dev_addr_set_sync(struct net_device *dev, const u8 *addr) [Severity: Low] This isn't a bug, but is the dev_ prefix a good fit for this helper? Documentation/networking/netdevices.rst describes the dev_xxx/netdev_xxx functions as the ones that take the instance lock themselves. The peer writer dev_set_mac_address_user() does take it: down_write(&dev_addr_sem); netdev_lock_ops(dev); ret = netif_set_mac_address(dev, ss, extack); dev_addr_set_sync() instead requires that the instance lock is not held. That said, the instance lock does not seem to cover dev->dev_addr or dev->dev_addrs. Neither field appears in the @lock kernel-doc of struct net_device, and dev_addr_add() already changes the same dev_addrs tree with only RTNL held. The existing dev_addr_* helpers don't follow the dev_xxx naming rule either. So this looks like a naming question, not a race. > +{ > + ASSERT_RTNL(); > + lockdep_assert_not_held(&dev_addr_sem); > + lockdep_assert_not_held(&dev->lock); [Severity: Low] With this contract, can ops-locked drivers use the helper from deferred work at all? Documentation/networking/netdevices.rst says: ndo_work: Synchronization: netdev instance lock for "ops locked" drivers, rtnl_lock() semaphore for all other drivers. An ops-locked driver running from netdev_work_proc() would hold dev->lock and not RTNL. It would fail both ASSERT_RTNL() and the dev->lock assertion here. A caller that ignored the contract and held dev->lock would take dev->lock before dev_addr_sem. That is the reverse of the order used in dev_set_mac_address_user() and do_setlink(): /* dev_addr_sem is an outer lock, enforce proper ordering */ down_write(&dev_addr_sem); netdev_lock_ops(dev); Lockdep would catch this through the assertions above. The only user in the series is enic, which isn't ops-locked. In enic_vf_admin_mac_work() it takes RTNL with rtnl_trylock() and doesn't hold dev->lock, so it meets the contract. Is it intended that only non-ops-locked callers can use the helper? If so, could the kernel-doc say so? > + > + down_write(&dev_addr_sem); > + dev_addr_set(dev, addr); > + up_write(&dev_addr_sem); > +} > +EXPORT_SYMBOL_GPL(dev_addr_set_sync); [Severity: Low] Nothing calls dev_addr_set_sync() at this commit. Could the commit message name the intended user? The later patch "enic: manage V2 VF station and administrative MAC" calls it from enic_vf_admin_mac_work() and enic_vf_admin_mac_refresh(). So the export is used by the end of the series. The commit message describes the problem in general terms: Drivers that publish a new address in response to firmware can bypass the write-side lock taken by the userspace MAC setter. Other drivers with the same pattern still update the address without dev_addr_sem. Examples are bnxt_update_vf_mac() in bnxt_sriov.c and drivers/net/vmxnet3/vmxnet3_drv.c. That bypass predates this patch, and the patch doesn't claim to convert those drivers. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-b4-enic-sriov-v2-vf-receive-control-v6-0-ca38950bbe07%40cisco.com