net: ethtool: let ops locked drivers run without rtnl_lock
Subsystems (15)
Jakub Kicinski
maintainercover net: ethtool: let ops locked drivers run without rtnl_lock
We have been slowly moving towards removing the rtnl_lock dependency in driver ops since the concept of "ops-locked" drivers have been introduced last year. Since last year will take the netdev instance lock before invoking any ndo or ethtool op of "ops-locked" drivers.
We dipped our toes into rtnl_lock-less ops with the queue binding API. Queue stats, NAPI, and other netdev-netlink objects are also queried without holding rtnl_lock already. It's time to take the next logical step and lift the requirement from ethtool ops.
The direct motivation for this patchset is that ethtool ops often involve communicating with device FW, and may take a long time to complete. Aggressive polling of device state on machines with 10+ NICs have been shown to significantly increase rtnl_lock pressure.
There's a handful of areas which still need rtnl_lock (see below). I decided to convert everything to rtnl_lock-less by default, and add a set of flags which let the drivers request rtnl_lock to still be taken. I don't love this, but I'm worried that opt-in would be even more confusing.
Known issues / exclusions:
- qdiscs - qdisc configuration currently assumes rtnl_lock, this is mostly impacting set_channels callback. qdisc config is probably the easiest one of the exclusions to tackle, it's fairly self-contained.
- features - even tho feature changes are (correctly) plumbed to the driver thru ndos they are part of ethtool uAPI. ethtool itself calls netdev_features_change() if it spotted device changing features in response to the request. And some drivers call it themselves. Since features have to propagate to upper and lower devices anything that touches features is quite hard to take from under rtnl_lock.
- phylink - phylink and SFP depend on rtnl_lock today, I suspect that this is purely for historic reasons. I started poking at it and don't really see a need for a global lock. But accessing the netdev instance lock from the SFP entry points will require some attention from the phylink folks.
- phydev - similar to phylink, looks quite doable. But no ops-locked driver currently has a phydev (fbnic only uses phylink) so phydev related paths retain a ASSERT_RTNL() for now.
Tested on mlx5, bnxt and fbnic.
Jakub Kicinski (14):
net: ethtool: cmis_cdb: hold instance lock for ops locked devices
net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
net: ethtool: serialize broadcast notification sequence allocation
net: ethtool: relax ethnl_req_get_phydev() locking assertion
net: ethtool: make dev->hwprov ops-protected
net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops
net: ethtool: optionally skip rtnl_lock on Netlink path for SET ops
net: ethtool: optionally skip rtnl_lock in cable test handlers
net: ethtool: optionally skip rtnl_lock in ethnl_tsinfo_dumpit()
net: ethtool: optionally skip rtnl_lock in ethnl_act_module_fw_flash()
net: ethtool: optionally skip rtnl_lock in RSS context handlers
net: ethtool: ioctl: concentrate the locking
net: ethtool: optionally skip rtnl_lock on IOCTL path
docs: net: ethtool: document ops-locked drivers and op_needs_rtnl
Documentation/networking/netdev-features.rst | 7 + Documentation/networking/netdevices.rst | 17 ++- include/linux/ethtool.h | 38 ++++- include/linux/netdevice.h | 3 + include/linux/phy_link_topology.h | 5 + include/net/netdev_lock.h | 17 +++ net/ethtool/common.h | 76 ++++++++++ net/ethtool/netlink.h | 1 - .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 + drivers/net/ethernet/google/gve/gve_ethtool.c | 2 + .../ethernet/mellanox/mlx5/core/en_ethtool.c | 3 + .../net/ethernet/mellanox/mlx5/core/en_rep.c | 2 + .../mellanox/mlx5/core/ipoib/ethtool.c | 2 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 5 + .../ethernet/microsoft/mana/mana_ethtool.c | 2 + drivers/net/netdevsim/ethtool.c | 1 + drivers/net/phy/phy_device.c | 3 + drivers/net/phy/phy_link_topology.c | 10 ++ net/core/dev_ioctl.c | 4 +- net/ethtool/cabletest.c | 12 +- net/ethtool/cmis_cdb.c | 3 + net/ethtool/cmis_fw_update.c | 8 +- net/ethtool/ioctl.c | 135 ++++++++++++++---- net/ethtool/linkinfo.c | 4 +- net/ethtool/linkmodes.c | 4 +- net/ethtool/mm.c | 5 +- net/ethtool/module.c | 8 +- net/ethtool/netlink.c | 62 +++++--- net/ethtool/phy.c | 1 - net/ethtool/rss.c | 21 +-- net/ethtool/tsconfig.c | 10 +- net/ethtool/tsinfo.c | 32 ++--- 32 files changed, 385 insertions(+), 122 deletions(-)
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 1/14 net: ethtool: cmis_cdb: hold instance lock for ops locked devices
FW module flashing was written so that the flashing happens without holding rtnl_lock. This allows flashing multiple modules at once. Current drivers can handle that well, but we should let drivers depend on the netdev instance lock. Instance lock is per netdev, and so is the module so we won't break parallel updates.
--- include/net/netdev_lock.h | 6 ++++++ net/ethtool/cmis_cdb.c | 3 +++ net/ethtool/cmis_fw_update.c | 8 ++------ net/ethtool/module.c | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-)
include/net/netdev_lock.h +6 -0
@@ -80,6 +80,12 @@ netdev_ops_assert_locked_or_invisible(const struct net_device *dev)netdev_ops_assert_locked (dev); } +static inline void netdev_assert_locked_if_ops (const struct net_device *dev) +{ +if (netdev_need_ops_lock (dev)) +netdev_assert_locked (dev); +} +static inline void netdev_lock_ops_compat (struct net_device *dev) {if (netdev_need_ops_lock (dev))
net/ethtool/cmis_cdb.c +3 -0
@@ -2,6 +2,7 @@#include <linux/ethtool.h> #include <linux/jiffies.h> +#include <net/netdev_lock.h> #include "common.h" #include "module_fw.h"
@@ -179,6 +180,7 @@ cmis_cdb_validate_password(struct ethtool_cmis_cdb *cdb, pe_pl = *((struct cmis_password_entry_pl *)page_data.data); pe_pl.password = params->password; +netdev_assert_locked_if_ops (dev); err = ops->set_module_eeprom_by_page (dev, &page_data, &extack);if (err <0 ) {if (extack._msg)
@@ -546,6 +548,7 @@ __ethtool_cmis_cdb_execute_cmd(struct net_device *dev,if (!page_data->data)return -ENOMEM ; +netdev_assert_locked_if_ops (dev); err = ops->set_module_eeprom_by_page (dev, page_data, &extack);if (err <0 ) {if (extack._msg)
net/ethtool/cmis_fw_update.c +2 -6
@@ -435,13 +435,9 @@ cmis_fw_update_commit_image(struct ethtool_cmis_cdb *cdb,static int cmis_fw_update_reset (struct net_device *dev) {__u32 reset_data =ETH_RESET_PHY ; -int ret; -netdev_lock_ops (dev); - ret = dev->ethtool_ops->reset (dev, &reset_data); -netdev_unlock_ops (dev); - -return ret; +netdev_assert_locked_if_ops (dev); +return dev->ethtool_ops->reset (dev, &reset_data); }void
net/ethtool/module.c +2 -0
@@ -226,7 +226,9 @@ static void module_flash_fw_work(struct work_struct *work) module_fw = container_of(work, struct ethtool_module_fw_flash, work); dev = module_fw->fw_update.dev; +netdev_lock_ops (dev);ethtool_cmis_fw_update (&module_fw->fw_update); +netdev_unlock_ops (dev);module_flash_fw_work_list_del (&module_fw->list);
Signature · 1 line
2.54.0
Re: [PATCH net-next 01/14] net: ethtool: cmis_cdb: hold instance lock for ops locked devices
Quoted 20 lines · Jakub Kicinski
FW module flashing was written so that the flashing happens without holding
rtnl_lock. This allows flashing multiple modules at once. Current drivers can handle that well, but we should let drivers depend on the netdev instance lock. Instance lock is per netdev, and so is the module so we won't break parallel updates.Signed-off-by Jakub Kicinski <[email protected]>--- include/net/netdev_lock.h | 6 ++++++ net/ethtool/cmis_cdb.c | 3 +++ net/ethtool/cmis_fw_update.c | 8 ++------ net/ethtool/module.c | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-)include/net/netdev_lock.h +0
-0
include/net/netdev_lock.h netdev_ops_assert_locked_or_invisible(const struct net_device *dev) · line 88
Quoted 9 lines
include/net/netdev_lock.h +6
-0@@ -80,6 +80,12 @@ netdev_ops_assert_locked_or_invisible(const struct net_device *dev)netdev_ops_assert_locked (dev); } +static inline void netdev_assert_locked_if_ops (const struct net_device *dev) +{ +if (netdev_need_ops_lock (dev)) +netdev_assert_locked (dev); +} +
Nit (because in the kernel naming is a competitive sport):
How about we name that netdev_assert_locked_ops() so it's clear that this checks if netdev_{lock,unlock}_ops() has been called?
I'm guessing the intention behind the name was to make it distinguishable from the legacy netdev_ops_assert_locked().
My suggestion would be to rename that one to netdev_assert_locked_ops_compat() following the netdev_{lock,unlock}_ops_compat() naming scheme. That should avoid confusion and provide a clear signal which one we're phasing out.
Symmetry is beautiful :-)
Jakub Kicinski
maintainerPATCH 2/14 net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
In reply to Jakub Kicinski__ethtool_get_link_ksettings() is exported and called from sysfs and many drivers. Looks like commit 2bcf4772e45a ("net: ethtool:
try to protect all callback with netdev instance lock") missed adding the lock around it. Not treating this as a fix because I don't think any driver cares at this point, but if we want to remove the rtnl_lock protection this will become critical.
--- include/linux/ethtool.h | 2 ++ net/ethtool/ioctl.c | 20 +++++++++++++++++--- net/ethtool/linkinfo.c | 4 ++-- net/ethtool/linkmodes.c | 4 ++-- 4 files changed, 23 insertions(+), 7 deletions(-)
include/linux/ethtool.h +2 -0
@@ -325,6 +325,8 @@ struct ethtool_link_ksettings {extern int __ethtool_get_link_ksettings (struct net_device *dev,struct ethtool_link_ksettings *link_ksettings); +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings);struct ethtool_keee {__ETHTOOL_DECLARE_LINK_MODE_MASK (supported);
net/ethtool/ioctl.c +17 -3
@@ -436,10 +436,10 @@ struct ethtool_link_usettings { };/* Internal kernel helper to query a device ethtool_link_settings. */ -int __ethtool_get_link_ksettings (struct net_device *dev, -struct ethtool_link_ksettings *link_ksettings) +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings) { -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (!dev->ethtool_ops->get_link_ksettings)return -EOPNOTSUPP ;
@@ -450,6 +450,20 @@ int __ethtool_get_link_ksettings(struct net_device *dev,memset (link_ksettings,0 ,sizeof (*link_ksettings));return dev->ethtool_ops->get_link_ksettings (dev, link_ksettings); } + +/* Convenience helper for callers that hold only rtnl_lock(). */ +int __ethtool_get_link_ksettings (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings) +{ +int ret; + +ASSERT_RTNL (); + +netdev_lock_ops (dev); + ret =ethtool_get_link_ksettings_locked (dev, link_ksettings); +netdev_unlock_ops (dev); +return ret; +}EXPORT_SYMBOL (__ethtool_get_link_ksettings);/* convert ethtool_link_usettings in user space to a kernel internal
net/ethtool/linkinfo.c +2 -2
@@ -34,7 +34,7 @@ static int linkinfo_prepare_data(const struct ethnl_req_info *req_base, ret =ethnl_ops_begin (dev);if (ret <0 )return ret; - ret =__ethtool_get_link_ksettings (dev, &data->ksettings); + ret =ethtool_get_link_ksettings_locked (dev, &data->ksettings);if (ret <0 )GENL_SET_ERR_MSG (info,"failed to retrieve link settings" );ethnl_ops_complete (dev);
@@ -104,7 +104,7 @@ ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info)bool mod = false;int ret; - ret =__ethtool_get_link_ksettings (dev, &ksettings); + ret =ethtool_get_link_ksettings_locked (dev, &ksettings);if (ret <0 ) {GENL_SET_ERR_MSG (info,"failed to retrieve link settings" );return ret;
net/ethtool/linkmodes.c +2 -2
@@ -39,7 +39,7 @@ static int linkmodes_prepare_data(const struct ethnl_req_info *req_base,if (ret <0 )return ret; - ret =__ethtool_get_link_ksettings (dev, &data->ksettings); + ret =ethtool_get_link_ksettings_locked (dev, &data->ksettings);if (ret <0 ) {GENL_SET_ERR_MSG (info,"failed to retrieve link settings" ); goto out;
@@ -324,7 +324,7 @@ ethnl_set_linkmodes(struct ethnl_req_info *req_info, struct genl_info *info)bool mod = false;int ret; - ret =__ethtool_get_link_ksettings (dev, &ksettings); + ret =ethtool_get_link_ksettings_locked (dev, &ksettings);if (ret <0 ) {GENL_SET_ERR_MSG (info,"failed to retrieve link settings" );return ret;
Signature · 1 line
2.54.0
Re: [PATCH net-next 02/14] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
Quoted 33 lines · Jakub Kicinski
__ethtool_get_link_ksettings()is exported and called from sysfs and many drivers. Looks like commit2bcf4772e45a("net: ethtool:
try to protect all callback with netdev instance lock") missed adding the lock around it. Not treating this as a fix because I don't think any driver cares at this point, but if we want to remove thertnl_lockprotection this will become critical.Signed-off-by Jakub Kicinski <[email protected]>--- include/linux/ethtool.h | 2 ++ net/ethtool/ioctl.c | 20 +++++++++++++++++--- net/ethtool/linkinfo.c | 4 ++-- net/ethtool/linkmodes.c | 4 ++-- 4 files changed, 23 insertions(+), 7 deletions(-)include/linux/ethtool.h +2
-0@@ -325,6 +325,8 @@ struct ethtool_link_ksettings {extern int __ethtool_get_link_ksettings (struct net_device *dev,struct ethtool_link_ksettings *link_ksettings); +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings);struct ethtool_keee {__ETHTOOL_DECLARE_LINK_MODE_MASK (supported);net/ethtool/ioctl.c +0
-0
net/ethtool/ioctl.c struct ethtool_link_usettings { · line 442
Quoted 10 lines
net/ethtool/ioctl.c +3
-3@@ -436,10 +436,10 @@ struct ethtool_link_usettings { };/* Internal kernel helper to query a device ethtool_link_settings. */ -int __ethtool_get_link_ksettings (struct net_device *dev, -struct ethtool_link_ksettings *link_ksettings) +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings) { -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);
Not sure why we're using the "compat" assertion here, which falls back to check if RTNL is held, instead of the newly introduced netdev_assert_locked_if_ops().
The contract here is that all callers are expected to hold the netdev lock (if needed), IIUC.
[...]
Nicolai Buchwitz
Reviewed-byRe: [PATCH net-next 02/14] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
Hi Jakub ^ 2
Quoted 30 lines · Jakub Sitnicki
Quoted 8 lines · Jakub Kicinski
__ethtool_get_link_ksettings()is exported and called from sysfs and many drivers. Looks like commit2bcf4772e45a("net: ethtool:
try to protect all callback with netdev instance lock") missed adding the lock around it. Not treating this as a fix because I don't think any driver cares at this point, but if we want to remove thertnl_lockprotection this will become critical.Signed-off-by Jakub Kicinski <[email protected]>[...]
Quoted 1 line
net/ethtool/ioctl.c +0
-0[...]
net/ethtool/ioctl.c struct ethtool_link_usettings { · line 442
Quoted 9 lines
/* Internal kernel helper to query a device
ethtool_link_settings. */net/ethtool/ioctl.c +3
-3-int __ethtool_get_link_ksettings (struct net_device *dev, -struct ethtool_link_ksettings *link_ksettings) +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings) { -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);Not sure why we're using the "compat" assertion here, which falls back to check if RTNL is held, instead of the newly introduced
netdev_assert_locked_if_ops().
Quoted 4 lines
The contract here is that all callers are expected to hold the netdev lock (if needed), IIUC.
[...]
AFAIU that's on purpose: the original helper had ASSERT_RTNL(), and legacy callers still enter with rtnl_lock via the wrapper. _if_ops would silently pass for them if rtnl ever went missing.
Thanks
Nicolai
Re: [PATCH net-next 02/14] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
Quoted 33 lines · Nicolai Buchwitz
Hi Jakub ^ 2
Quoted 15 lines · Jakub Sitnicki
Quoted 7 lines · Jakub Kicinski
__ethtool_get_link_ksettings()is exported and called from sysfs and many drivers. Looks like commit2bcf4772e45a("net: ethtool:
try to protect all callback with netdev instance lock") missed adding the lock around it. Not treating this as a fix because I don't think any driver cares at this point, but if we want to remove thertnl_lockprotection this will become critical.Signed-off-by Jakub Kicinski <[email protected]>[...]
Quoted 1 line
net/ethtool/ioctl.c +0
-0[...]
Quoted 14 lines
net/ethtool/ioctl.c struct ethtool_link_usettings { · line 442
Quoted 8 lines
/* Internal kernel helper to query a device
ethtool_link_settings. */net/ethtool/ioctl.c +3
-3-int __ethtool_get_link_ksettings (struct net_device *dev, -struct ethtool_link_ksettings *link_ksettings) +int ethtool_get_link_ksettings_locked (struct net_device *dev, +struct ethtool_link_ksettings *link_ksettings) { -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);Not sure why we're using the "compat" assertion here, which falls back to check if RTNL is held, instead of the newly introduced
netdev_assert_locked_if_ops().
The contract here is that all callers are expected to hold the netdev lock (if needed), IIUC.
[...]
Quoted 3 lines
AFAIU that's on purpose: the original helper had
ASSERT_RTNL(), and legacy callers still enter withrtnl_lockvia the wrapper._if_opswould silently pass for them if rtnl ever went missing.
But the legacy callers continue using __ethtool_get_link_ksettings(), which has an explicit ASSERT_RTNL(), so I still don't get it:
| +/* Convenience helper for callers that hold only rtnl_lock(). */
| +int __ethtool_get_link_ksettings(struct net_device *dev,
| + struct ethtool_link_ksettings *link_ksettings)
| +{
| + int ret;
| +
| + ASSERT_RTNL();
| +
| + netdev_lock_ops(dev);
| + ret = ethtool_get_link_ksettings_locked(dev, link_ksettings);
| + netdev_unlock_ops(dev);
| + return ret;
| +}
| EXPORT_SYMBOL(__ethtool_get_link_ksettings);Anyway, no sense speculating. Let's wait for Jakub.
Jakub Kicinski
maintainerRe: [PATCH net-next 02/14] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
Quoted 30 lines · On Tue, 02 Jun 2026 13:35:33 +0200 Jakub Sitnicki wrote:
Quoted 10 lines · Nicolai Buchwitz
Quoted 6 lines
Not sure why we're using the "compat" assertion here, which falls back to check if RTNL is held, instead of the newly introduced
netdev_assert_locked_if_ops().
The contract here is that all callers are expected to hold the netdev lock (if needed), IIUC.
[...]AFAIU that's on purpose: the original helper had
ASSERT_RTNL(), and legacy callers still enter withrtnl_lockvia the wrapper._if_opswould silently pass for them if rtnl ever went missing.But the legacy callers continue using
__ethtool_get_link_ksettings(), which has an explicitASSERT_RTNL(), so I still don't get it:| +/* Convenience helper for callers that hold only rtnl_lock(). */ | +int __ethtool_get_link_ksettings(struct net_device *dev, | + struct ethtool_link_ksettings *link_ksettings) | +{ | + int ret; | + | + ASSERT_RTNL(); | + | + netdev_lock_ops(dev); | + ret = ethtool_get_link_ksettings_locked(dev, link_ksettings); | + netdev_unlock_ops(dev); | + return ret; | +} | EXPORT_SYMBOL(__ethtool_get_link_ksettings);
Quoted 1 line
Anyway, no sense speculating. Let's wait for Jakub.
You're right, I probably didn't use the .._if_ops.. because the spelling was kinda unusual. Looking at my local tree now I seem to have switched to the _compat helper like you are suggesting when renaming things.
I also renamed the new helper to netif_get_link_ksettings() since that's the naming scheme we followed elsewhere (the netif_ prefix for helpers called with ops lock already held).
I've been digging thru the drivers calling __ethtool_get_link_ksettings() since yesterday. Turns out I was quite optimistic on none of them holding the ops lock :( Hopefully I'm getting close to posting the first chunk of v2 (patches 1+2 from here plus all the driver adjustments needed).
Jakub Kicinski
maintainerPATCH 3/14 net: ethtool: serialize broadcast notification sequence allocation
In reply to Jakub Kicinskiethnl_bcast_seq is a global counter stamped into the nlmsg_seq field of every multicast notification, allowing userspace to detect dropped messages. Today the ordering is achieved by using rtnl_lock()
Moving forward we will want ethtool ops to run under just the netdev instance lock so to establish ordering we need a separate lock for notifications. With the netdev instance locks operations on different devices may bypass each other but the expectation is that it should not matter. What we need to prevent is:
- notification IDs getting out of order
- operations on one device getting out of order
For simplicity defer allocating the ID of the notification right before the notification is delivered. This removes the need for special handling in ethnl_rss_create_send_ntf().
--- net/ethtool/netlink.h | 1 - net/ethtool/netlink.c | 28 +++++++++++++++++----------- net/ethtool/rss.c | 1 - 3 files changed, 17 insertions(+), 13 deletions(-)
net/ethtool/netlink.h +0 -1
@@ -10,7 +10,6 @@struct ethnl_req_info ; -u32 ethnl_bcast_seq_next (void ); int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, const struct nlattr *nest, struct net *net, struct netlink_ext_ack *extack,
net/ethtool/netlink.c +17 -11
@@ -13,6 +13,12 @@static struct genl_family ethtool_genl_family;static bool ethnl_ok__read_mostly ; + +/* Serializes broadcast notification sequence allocation with the multicast +* send, so that userspace observes nlmsg_seq monotonic in receive order +* regardless of which lock the caller holds (rtnl or instance lock). +*/ +static DEFINE_MUTEX (ethnl_bcast_lock);static u32 ethnl_bcast_seq;#define ETHTOOL_FLAGS_BASIC (ETHTOOL_FLAG_COMPACT_BITSETS | \
@@ -82,12 +88,6 @@ static void ethnl_sock_priv_destroy(void *priv) } } -u32 ethnl_bcast_seq_next (void ) -{ -ASSERT_RTNL (); -return ++ethnl_bcast_seq; -} -int ethnl_ops_begin (struct net_device *dev) {int ret;
@@ -329,8 +329,7 @@ void *ethnl_dump_put(struct sk_buff *skb, struct netlink_callback *cb, u8 cmd)void *ethnl_bcastmsg_put (struct sk_buff *skb,u8 cmd) { -return genlmsg_put (skb,0 , ++ethnl_bcast_seq, ðtool_genl_family,0 , - cmd); +return genlmsg_put (skb,0 ,0 , ðtool_genl_family,0 , cmd); }void *ethnl_unicast_put (struct sk_buff *skb,u32 portid,u32 seq,u8 cmd)
@@ -340,8 +339,15 @@ void *ethnl_unicast_put(struct sk_buff *skb, u32 portid, u32 seq, u8 cmd)int ethnl_multicast (struct sk_buff *skb,struct net_device *dev) { -return genlmsg_multicast_netns (ðtool_genl_family,dev_net (dev), skb, -0 ,ETHNL_MCGRP_MONITOR ,GFP_KERNEL ); +struct nlmsghdr *nlh =nlmsg_hdr (skb); +int ret; + +mutex_lock (ðnl_bcast_lock); + nlh->nlmsg_seq = ++ethnl_bcast_seq; + ret =genlmsg_multicast_netns (ðtool_genl_family,dev_net (dev), skb, +0 ,ETHNL_MCGRP_MONITOR ,GFP_KERNEL ); +mutex_unlock (ðnl_bcast_lock); +return ret; }/* GET request helpers */
@@ -1081,7 +1087,7 @@ void ethnl_notify(struct net_device *dev, unsigned int cmd, {if (unlikely (!ethnl_ok))return ; -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (likely (cmd <ARRAY_SIZE (ethnl_notify_handlers) && ethnl_notify_handlers[cmd]))
net/ethtool/rss.c +0 -1
@@ -995,7 +995,6 @@ ethnl_rss_create_send_ntf(const struct sk_buff *rsp, struct net_device *dev) nlh =nlmsg_hdr (ntf);/* Convert the reply into a notification */ nlh->nlmsg_pid =0 ; - nlh->nlmsg_seq =ethnl_bcast_seq_next (); genl_hdr =nlmsg_data (nlh); genl_hdr->cmd =ETHTOOL_MSG_RSS_CREATE_NTF ;
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 4/14 net: ethtool: relax ethnl_req_get_phydev() locking assertion
In reply to Jakub Kicinskiphydev <> netdev linking and lifecycle depends on rtnl_lock. We want to switch to instance locks for most ethtool ops. Let's add an assert that ops locked devices don't use phydev today. If one does we can either opt the phy ops out of being purely ops locked, or do deeper surgery to make phy locking ops-compatible. I don't think there's any fundamental challenge to make that work.
--- include/linux/phy_link_topology.h | 5 +++++ drivers/net/phy/phy_link_topology.c | 8 ++++++++ net/ethtool/netlink.c | 6 ++++-- net/ethtool/phy.c | 1 - 4 files changed, 17 insertions(+), 3 deletions(-)
include/linux/phy_link_topology.h +5 -0
@@ -36,6 +36,11 @@ struct phy_device_node {struct phy_device *phy; }; +static inline bool phy_link_topo_empty (struct net_device *dev) +{ +return !dev->link_topo; +} +#if IS_ENABLED (CONFIG_PHYLIB ) int phy_link_topo_add_phy(struct net_device *dev, struct phy_device *phy,
drivers/net/phy/phy_link_topology.c +8 -0
@@ -10,6 +10,7 @@#include <linux/phy.h> #include <linux/rtnetlink.h> #include <linux/xarray.h> +#include <net/netdev_lock.h> static int netdev_alloc_phy_link_topology (struct net_device *dev) {
@@ -35,6 +36,13 @@ int phy_link_topo_add_phy(struct net_device *dev,struct phy_device_node *pdn;int ret; +/* ethtool ops may run without rtnl_lock, and rtnl_lock is what +* currently protects the PHY topology. No driver currently mixes +* the two, flag if someone tries. See also ethnl_req_get_phydev(). +*/ +if (WARN_ON_ONCE (netdev_need_ops_lock (dev))) +return -EOPNOTSUPP ; +if (!topo) { ret =netdev_alloc_phy_link_topology (dev);if (ret)
net/ethtool/netlink.c +4 -2
@@ -226,11 +226,13 @@ struct phy_device *ethnl_req_get_phydev(const struct ethnl_req_info *req_info, {struct phy_device *phydev; -ASSERT_RTNL (); -if (!req_info->dev)return NULL ; +/* If there is no PHY in sight there's no need for assert locking */ +if (!phy_link_topo_empty (req_info->dev)) +ASSERT_RTNL (); +if (!req_info->phy_index)return req_info->dev->phydev;
net/ethtool/phy.c +0 -1
@@ -78,7 +78,6 @@ static int phy_prepare_data(const struct ethnl_req_info *req_info,struct phy_device *phydev;int ret; -/* RTNL is held by the caller */ phydev =ethnl_req_get_phydev (req_info, tb,ETHTOOL_A_PHY_HEADER , info->extack);if (IS_ERR_OR_NULL (phydev))
Signature · 1 line
2.54.0
Re: [PATCH net-next 04/14] net: ethtool: relax ethnl_req_get_phydev() locking assertion
Hi,
Quoted 7 lines · Jakub Kicinski
phydev <> netdev linking and lifecycle depends on
rtnl_lock. We want to switch to instance locks for most ethtool ops. Let's add an assert that ops locked devices don't use phydev today. If one does we can either opt the phy ops out of being purely ops locked, or do deeper surgery to make phy locking ops-compatible. I don't think there's any fundamental challenge to make that work.
Yeah untangling phylink/SFP/phylib from rtnl will be needed soon indeed, quite the can of worms...
But for the topo part, this change should do the trick.
At some point we'll need to convert a more embeded-oriented MAC driver to being ops-locked, to get a good idea of the amount of work in front of us.
Most of the constraints come from the different lifetimes of phy_device, sfp-bus and net_device, RTNL is the easy way to guarantee that the netdev doesn't dissapear under our feet.
Andrew and Russell were careful to get people to annotate the RTNL dependencies with assertions, this should make it easier to tackle the conversion :)
For now,
Maxime
Quoted 83 lines
Signed-off-by Jakub Kicinski <[email protected]>--- include/linux/phy_link_topology.h | 5 +++++ drivers/net/phy/phy_link_topology.c | 8 ++++++++ net/ethtool/netlink.c | 6 ++++-- net/ethtool/phy.c | 1 - 4 files changed, 17 insertions(+), 3 deletions(-)include/linux/phy_link_topology.h +5
-0@@ -36,6 +36,11 @@ struct phy_device_node {struct phy_device *phy; }; +static inline bool phy_link_topo_empty (struct net_device *dev) +{ +return !dev->link_topo; +} +#if IS_ENABLED (CONFIG_PHYLIB ) int phy_link_topo_add_phy(struct net_device *dev, struct phy_device *phy,drivers/net/phy/phy_link_topology.c +8
-0@@ -10,6 +10,7 @@#include <linux/phy.h> #include <linux/rtnetlink.h> #include <linux/xarray.h> +#include <net/netdev_lock.h> static int netdev_alloc_phy_link_topology (struct net_device *dev) {@@ -35,6 +36,13 @@ int phy_link_topo_add_phy(struct net_device *dev,struct phy_device_node *pdn;int ret; +/* ethtool ops may run without rtnl_lock, and rtnl_lock is what +* currently protects the PHY topology. No driver currently mixes +* the two, flag if someone tries. See also ethnl_req_get_phydev(). +*/ +if (WARN_ON_ONCE (netdev_need_ops_lock (dev))) +return -EOPNOTSUPP ; +if (!topo) { ret =netdev_alloc_phy_link_topology (dev);if (ret)net/ethtool/netlink.c +4
-2@@ -226,11 +226,13 @@ struct phy_device *ethnl_req_get_phydev(const struct ethnl_req_info *req_info, {struct phy_device *phydev; -ASSERT_RTNL (); -if (!req_info->dev)return NULL ; +/* If there is no PHY in sight there's no need for assert locking */ +if (!phy_link_topo_empty (req_info->dev)) +ASSERT_RTNL (); +if (!req_info->phy_index)return req_info->dev->phydev;net/ethtool/phy.c +0
-1@@ -78,7 +78,6 @@ static int phy_prepare_data(const struct ethnl_req_info *req_info,struct phy_device *phydev;int ret; -/* RTNL is held by the caller */ phydev =ethnl_req_get_phydev (req_info, tb,ETHTOOL_A_PHY_HEADER , info->extack);if (IS_ERR_OR_NULL (phydev))
Jakub Kicinski
maintainerRe: [PATCH net-next 04/14] net: ethtool: relax ethnl_req_get_phydev() locking assertion
Quoted 14 lines · On Fri, 29 May 2026 10:43:04 +0200 Maxime Chevallier wrote:
Quoted 7 lines · Jakub Kicinski
phydev <> netdev linking and lifecycle depends on
rtnl_lock. We want to switch to instance locks for most ethtool ops. Let's add an assert that ops locked devices don't use phydev today. If one does we can either opt the phy ops out of being purely ops locked, or do deeper surgery to make phy locking ops-compatible. I don't think there's any fundamental challenge to make that work.Yeah untangling phylink/SFP/phylib from rtnl will be needed soon indeed, quite the can of worms...
But for the topo part, this change should do the trick.
Quoted 7 lines
At some point we'll need to convert a more embeded-oriented MAC driver to being ops-locked, to get a good idea of the amount of work in front of us.
Most of the constraints come from the different lifetimes of
phy_device, sfp-bus andnet_device, RTNL is the easy way to guarantee that the netdev doesn't dissapear under our feet.
True, I was thinking about it from an integrated driver perspective where the same driver spawns all elements. In that case it's mostly a matter of pointing them all to the right netdev instance lock. But we'll figure it out :)
Quoted 3 lines
Andrew and Russell were careful to get people to annotate the RTNL dependencies with assertions, this should make it easier to tackle the conversion :)
Nicolai Buchwitz
Reviewed-byRe: [PATCH net-next 04/14] net: ethtool: relax ethnl_req_get_phydev() locking assertion
In reply to Maxime ChevallierHi Maxime & Jakub
Quoted 20 lines · Maxime Chevallier
Hi,
Quoted 7 lines · Jakub Kicinski
phydev <> netdev linking and lifecycle depends on
rtnl_lock. We want to switch to instance locks for most ethtool ops. Let's add an assert that ops locked devices don't use phydev today. If one does we can either opt the phy ops out of being purely ops locked, or do deeper surgery to make phy locking ops-compatible. I don't think there's any fundamental challenge to make that work.Yeah untangling phylink/SFP/phylib from rtnl will be needed soon indeed, quite the can of worms...
But for the topo part, this change should do the trick.
At some point we'll need to convert a more embeded-oriented MAC driver to being ops-locked, to get a good idea of the amount of work in front of us.
Quoted 7 lines
Most of the constraints come from the different lifetimes of
phy_device, sfp-bus andnet_device, RTNL is the easy way to guarantee that the netdev doesn't dissapear under our feet.Andrew and Russell were careful to get people to annotate the RTNL dependencies with assertions, this should make it easier to tackle the conversion :)
If you're looking for a concrete candidate, macb seems like a reasonable one. It IMHO has a broad user base with zynq and rp1, uses phylink (with the phylink rtnl_lock dependency you flagged), and gets pretty active review attention from Théo and others.
stmmac would be also a sane choice, but others know that code base better than me :) Happy to look at it for macb once the prerequisites land.
Quoted 1 line
[...]
Thanks Nicolai
Jakub Kicinski
maintainerPATCH 5/14 net: ethtool: make dev->hwprov ops-protected
In reply to Jakub Kicinskidev->hwprov tracks the active hwtstamp provider for the device. Make it ops protected (instance lock if the netdev driver opts into holding instance lock around callbacks, otherwise rtnl_lock).
hwprov is written in
- drivers/net/phy/phy_device.c
phydev and ops protection don't currently mix, add a comment
- net/ethtool/
as of now holds both rtnl lock and ops lock, this one will soon only hold one lock or the other
read in:
- net/core/dev_ioctl.c
holds both rtnl lock and ops lock
- net/core/timestamping.c
RCU reader
--- include/linux/netdevice.h | 3 +++ include/net/netdev_lock.h | 11 +++++++++++ drivers/net/phy/phy_device.c | 3 +++ drivers/net/phy/phy_link_topology.c | 4 +++- net/core/dev_ioctl.c | 4 ++-- net/ethtool/tsconfig.c | 10 ++++++---- 6 files changed, 28 insertions(+), 7 deletions(-)
include/linux/netdevice.h +3 -0
@@ -2584,6 +2584,9 @@ struct net_device {* Double protects: * @up, @moving_ns, @nd_net, @xdp_features * +* Ops protects: +* @hwprov +* * Double ops protects: * @real_num_rx_queues, @real_num_tx_queues *
include/net/netdev_lock.h +11 -0
@@ -102,6 +102,14 @@ static inline void netdev_unlock_ops_compat(struct net_device *dev)rtnl_unlock (); } +/* Matching "ops protected" category from netdevice.h */ +static inline int netdev_ops_is_locked (const struct net_device *dev) +{ +if (netdev_need_ops_lock (dev)) +return lockdep_is_held (&dev->lock); +return lockdep_rtnl_is_held (); +} +static inline int netdev_lock_cmp_fn (const struct lockdep_map *a,const struct lockdep_map *b) {
@@ -138,6 +146,9 @@ static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,#define netdev_lock_dereference (p, dev) \ rcu_dereference_protected(p, lockdep_is_held(&(dev)->lock)) +#define netdev_ops_lock_dereference (p, dev) \ + rcu_dereference_protected(p, netdev_ops_is_locked(dev)) +int netdev_debug_event (struct notifier_block *nb,unsigned long event,void *ptr);
drivers/net/phy/phy_device.c +3 -0
@@ -1935,6 +1935,9 @@ void phy_detach(struct phy_device *phydev)if (dev) {struct hwtstamp_provider *hwprov; +/* hwprov may technically be protected by ops lock but +* not for devices with a phydev, see phy_link_topo_add_phy() +*/ hwprov =rtnl_dereference (dev->hwprov);/* Disable timestamp if it is the one selected */ if (hwprov && hwprov->phydev == phydev) {
drivers/net/phy/phy_link_topology.c +3 -1
@@ -38,7 +38,9 @@ int phy_link_topo_add_phy(struct net_device *dev,/* ethtool ops may run without rtnl_lock, and rtnl_lock is what * currently protects the PHY topology. No driver currently mixes -* the two, flag if someone tries. See also ethnl_req_get_phydev(). +* the two, flag if someone tries. See also: +* - ethnl_req_get_phydev() +* - phy_detach() */ if (WARN_ON_ONCE (netdev_need_ops_lock (dev)))return -EOPNOTSUPP ;
net/core/dev_ioctl.c +2 -2
@@ -260,7 +260,7 @@ int dev_get_hwtstamp_phylib(struct net_device *dev, {struct hwtstamp_provider *hwprov; - hwprov =rtnl_dereference (dev->hwprov); + hwprov =netdev_ops_lock_dereference (dev->hwprov, dev);if (hwprov) { cfg->qualifier = hwprov->desc.qualifier; if (hwprov->source == HWTSTAMP_SOURCE_PHYLIB &&
@@ -337,7 +337,7 @@ int dev_set_hwtstamp_phylib(struct net_device *dev,bool phy_ts;int err; - hwprov =rtnl_dereference (dev->hwprov); + hwprov =netdev_ops_lock_dereference (dev->hwprov, dev);if (hwprov) {if (hwprov->source ==HWTSTAMP_SOURCE_PHYLIB && hwprov->phydev) {
net/ethtool/tsconfig.c +6 -4
@@ -2,6 +2,7 @@#include <linux/net_tstamp.h> #include <linux/ptp_clock_kernel.h> +#include <net/netdev_lock.h> #include "bitset.h" #include "common.h"
@@ -57,7 +58,7 @@ static int tsconfig_prepare_data(const struct ethnl_req_info *req_base, data->hwtst_config.flags = cfg.flags; data->hwprov_desc.index =-1 ; - hwprov =rtnl_dereference (dev->hwprov); + hwprov =netdev_ops_lock_dereference (dev->hwprov, dev);if (hwprov) { data->hwprov_desc.index = hwprov->desc.index; data->hwprov_desc.qualifier = hwprov->desc.qualifier;
@@ -213,7 +214,7 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info)return -ENOMEM ; } -ASSERT_RTNL (); +netdev_ops_assert_locked (dev); reply_data->base.dev = dev; ret =tsconfig_prepare_data (&req_info->base, &reply_data->base, info);if (ret <0 )
@@ -316,7 +317,7 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base,struct hwtstamp_provider_desc __hwprov_desc = {.index =-1 };struct hwtstamp_provider *__hwprov; - __hwprov =rtnl_dereference (dev->hwprov); + __hwprov =netdev_ops_lock_dereference (dev->hwprov, dev);if (__hwprov) { __hwprov_desc.index = __hwprov->desc.index; __hwprov_desc.qualifier = __hwprov->desc.qualifier;
@@ -414,7 +415,8 @@ static int ethnl_set_tsconfig(struct ethnl_req_info *req_base, goto err_free_hwprov;/* Change the selected hwtstamp source */ - __hwprov =rcu_replace_pointer_rtnl (dev->hwprov, hwprov); + __hwprov =rcu_replace_pointer (dev->hwprov, hwprov, +netdev_ops_is_locked (dev));if (__hwprov)kfree_rcu (__hwprov, rcu_head); }
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 6/14 net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops
In reply to Jakub Kicinskiethnl_default_doit() and ethnl_default_dump_one() are both used exclusively for GET callbacks (former to get info for a single device or get global strings). ops-locked devices don't need rtnl_lock for GET callbacks, stop taking it.
Introduce an opt-out mechanism for devices which use phylink (fbnic) since phylink currently depends on rtnl_lock protection. Subsequent patches will add more exceptions, anyway. Practically the new helpers for judging if command needs rtnl_lock could also call netdev_need_ops_lock() but I find that it makes the code in the callers slightly less obvious.
Add a helper for IOCTLs already, even tho its unused so that we can keep them in sync as the series progresses.
This is the first user-visible step of moving ethtool ops out from under rtnl. Subsequent patches do the same for SET ops, as well as the ioctl path.
--- include/linux/ethtool.h | 18 +++++++- net/ethtool/common.h | 46 +++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 2 + net/ethtool/mm.c | 5 +- net/ethtool/netlink.c | 19 ++++++-- 5 files changed, 83 insertions(+), 7 deletions(-)
include/linux/ethtool.h +17 -1
@@ -930,6 +930,13 @@ struct kernel_ethtool_ts_info {u32 rx_filters; }; +/* Bits for ethtool_ops::op_needs_rtnl +* LINKSETTINGS cover a number of commands, but in most cases we want to keep +* these bits separate, per GET and SET. GET is much easier to "unlock". +*/ +#define ETHTOOL_OP_NEEDS_RTNL_LINKSETTINGS BIT(0) +#define ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM BIT(1) +/** * struct ethtool_ops - optional netdev operations * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
@@ -956,6 +963,14 @@ struct kernel_ethtool_ts_info {* @supported_coalesce_params: supported types of interrupt coalescing. * @supported_ring_params: supported ring params. * @supported_hwtstamp_qualifiers: bitfield of supported hwtstamp qualifier. +* @op_needs_rtnl: mask of %ETHTOOL_OP_NEEDS_RTNL_* bits. +* For use with ops-locked drivers (ignored otherwise). Selects which +* ethtool callbacks driver needs to still be executed under rtnl_lock +* (in addition to the netdev instance lock). +* The following commonly used core APIs currently require rtnl_lock +* (this list may not be exhaustive): +* - phylink helpers (note that phydev is currently unsupported!) +* * @get_drvinfo: Report driver/device information. Modern drivers no * longer have to implement this callback. Most fields are * correctly filled in by the core using system information, or
@@ -1155,7 +1170,7 @@ struct kernel_ethtool_ts_info {* * All operations are optional (i.e. the function pointer may be set * to %NULL) and callers must take this into account. Callers must -* hold the RTNL lock. +* hold the RTNL lock or netdev instance lock (see @op_needs_rtnl). * * See the structures used by these operations for further documentation. * Note that for all operations using a structure ending with a zero-
@@ -1178,6 +1193,7 @@ struct ethtool_ops {u32 supported_coalesce_params;u32 supported_ring_params;u32 supported_hwtstamp_qualifiers; +u32 op_needs_rtnl;void (*get_drvinfo)(struct net_device *,struct ethtool_drvinfo *);int (*get_regs_len)(struct net_device *);void (*get_regs)(struct net_device *,struct ethtool_regs *,void *);
net/ethtool/common.h +46 -0
52 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +2 -0
@@ -2020,6 +2020,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT | ETHTOOL_RING_USE_HDS_THRS, .rxfh_max_num_contexts = FBNIC_RPC_RSS_TBL_COUNT, + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_LINKSETTINGS | + ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM, .get_drvinfo = fbnic_get_drvinfo, .get_regs_len = fbnic_get_regs_len, .get_regs = fbnic_get_regs,
net/ethtool/mm.c +3 -2
@@ -246,8 +246,9 @@ const struct ethnl_request_ops ethnl_mm_request_ops = { };/* Returns whether a given device supports the MAC merge layer -* (has an eMAC and a pMAC). Must be called under rtnl_lock() and -* ethnl_ops_begin(). +* (has an eMAC and a pMAC). Must be called under whichever lock +* netdev_ops_assert_locked() accepts (rtnl for traditional drivers, +* the netdev instance lock for ops-locked ones) and ethnl_ops_begin(). */ bool __ethtool_dev_mm_supported (struct net_device *dev) {
net/ethtool/netlink.c +15 -4
@@ -7,6 +7,7 @@#include <linux/phy_link_topology.h> #include <linux/pm_runtime.h> +#include "common.h" #include "module_fw.h" #include "netlink.h"
@@ -509,6 +510,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)struct ethnl_req_info *req_info =NULL ;const u8 cmd = info->genlhdr->cmd;const struct ethnl_request_ops *ops; +bool need_rtnl = false;int hdr_len, reply_len;struct sk_buff *rskb;void *reply_payload;
@@ -535,13 +537,17 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)ethnl_init_reply_data (reply_data, ops, req_info->dev);if (req_info->dev) { -rtnl_lock (); + need_rtnl = !netdev_need_ops_lock (req_info->dev) || +ethtool_nl_msg_needs_rtnl (req_info->dev, cmd); +if (need_rtnl) +rtnl_lock ();netdev_lock_ops (req_info->dev); } ret = ops->prepare_data (req_info, reply_data, info);if (req_info->dev) {netdev_unlock_ops (req_info->dev); -rtnl_unlock (); +if (need_rtnl) +rtnl_unlock (); }if (ret <0 ) goto err_dev;
@@ -589,6 +595,7 @@ static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev,const struct ethnl_dump_ctx *ctx, const struct genl_info *info) { + bool need_rtnl;void *ehdr;int ret;
@@ -599,11 +606,15 @@ static int ethnl_default_dump_one(struct sk_buff *skb, struct net_device *dev,return -EMSGSIZE ;ethnl_init_reply_data (ctx->reply_data, ctx->ops, dev); -rtnl_lock (); + need_rtnl = !netdev_need_ops_lock (dev) || +ethtool_nl_msg_needs_rtnl (dev, ctx->ops->request_cmd); +if (need_rtnl) +rtnl_lock ();netdev_lock_ops (dev); ret = ctx->ops->prepare_data (ctx->req_info, ctx->reply_data, info);netdev_unlock_ops (dev); -rtnl_unlock (); +if (need_rtnl) +rtnl_unlock ();if (ret <0 ) goto out_cancel; ret =ethnl_fill_reply_header (skb, dev, ctx->ops->hdr_attr);
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 7/14 net: ethtool: optionally skip rtnl_lock on Netlink path for SET ops
In reply to Jakub KicinskiMake ethtool not take rtnl_lock for SET commands when operation is performed on an ops-locked driver. cfg/cfg_pending are now ops-locked, since only ethtool modifies them.
Some SET driver callbacks will still need rtnl_lock, most notably those which may end up calling netdev_update_features() or the qdisc layer (via netif_set_real_num_tx_queues()). Let drivers selectively opt back into the rtnl_lock with a new bitfield in ops.
We need two helpers since Netlink and ioctl cmds have different values. Keep the helpers side by side in common.h to make sure they get updated together, even tho they will only get called from ioctl.c and netlink.c.
SET commands which don't use ethnl_default_set_doit() are converted by subsequent commits.
--- include/linux/ethtool.h | 8 +++++ include/linux/netdevice.h | 2 +- net/ethtool/common.h | 30 +++++++++++++++++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 +++ drivers/net/ethernet/google/gve/gve_ethtool.c | 2 ++ .../ethernet/mellanox/mlx5/core/en_ethtool.c | 3 ++ .../net/ethernet/mellanox/mlx5/core/en_rep.c | 2 ++ .../mellanox/mlx5/core/ipoib/ethtool.c | 2 ++ .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 5 +++- .../ethernet/microsoft/mana/mana_ethtool.c | 2 ++ drivers/net/netdevsim/ethtool.c | 1 + net/ethtool/netlink.c | 9 ++++-- 12 files changed, 66 insertions(+), 4 deletions(-)
include/linux/ethtool.h +8 -0
@@ -936,6 +936,12 @@ struct kernel_ethtool_ts_info {*/ #define ETHTOOL_OP_NEEDS_RTNL_LINKSETTINGS BIT(0)#define ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM BIT(1) +#define ETHTOOL_OP_NEEDS_RTNL_SPFLAGS BIT(2) +#define ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM BIT(3) +#define ETHTOOL_OP_NEEDS_RTNL_SCHANNELS BIT(4) +#define ETHTOOL_OP_NEEDS_RTNL_SCOALESCE BIT(5) +#define ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM BIT(6) +#define ETHTOOL_OP_NEEDS_RTNL_RSS BIT(7)/** * struct ethtool_ops - optional netdev operations
@@ -970,6 +976,8 @@ struct kernel_ethtool_ts_info {* The following commonly used core APIs currently require rtnl_lock * (this list may not be exhaustive): * - phylink helpers (note that phydev is currently unsupported!) +* - netdev_update_features() +* - netif_set_real_num_tx_queues() * * @get_drvinfo: Report driver/device information. Modern drivers no * longer have to implement this callback. Most fields are
include/linux/netdevice.h +1 -1
@@ -2585,7 +2585,7 @@ struct net_device {* @up, @moving_ns, @nd_net, @xdp_features * * Ops protects: -* @hwprov +* @cfg, @cfg_pending, @hwprov * * Double ops protects: * @real_num_rx_queues, @real_num_tx_queues
net/ethtool/common.h +30 -0
@@ -95,10 +95,24 @@ ethtool_nl_msg_needs_rtnl(const struct net_device *dev, u8 cmd)switch (cmd) {case ETHTOOL_MSG_LINKINFO_GET : +case ETHTOOL_MSG_LINKINFO_SET :case ETHTOOL_MSG_LINKMODES_GET : +case ETHTOOL_MSG_LINKMODES_SET :return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_LINKSETTINGS ; +case ETHTOOL_MSG_PRIVFLAGS_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SPFLAGS ; +case ETHTOOL_MSG_RINGS_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SRINGPARAM ; +case ETHTOOL_MSG_CHANNELS_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SCHANNELS ; +case ETHTOOL_MSG_COALESCE_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SCOALESCE ;case ETHTOOL_MSG_PAUSE_GET :return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_GPAUSEPARAM ; +case ETHTOOL_MSG_PAUSE_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SPAUSEPARAM ; +case ETHTOOL_MSG_RSS_SET : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_RSS ; }return false; }
@@ -119,9 +133,25 @@ ethtool_ioctl_needs_rtnl(const struct net_device *dev, u32 ethcmd)switch (ethcmd) {case ETHTOOL_GLINKSETTINGS :case ETHTOOL_GSET : +case ETHTOOL_SLINKSETTINGS : +case ETHTOOL_SSET :return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_LINKSETTINGS ; +case ETHTOOL_SPFLAGS : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SPFLAGS ; +case ETHTOOL_SRINGPARAM : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SRINGPARAM ; +case ETHTOOL_SCHANNELS : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SCHANNELS ; +case ETHTOOL_SCOALESCE : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SCOALESCE ;case ETHTOOL_GPAUSEPARAM :return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_GPAUSEPARAM ; +case ETHTOOL_SPAUSEPARAM : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_SPAUSEPARAM ; +case ETHTOOL_SRSSH : +case ETHTOOL_SRXFH : +case ETHTOOL_SRXFHINDIR : +return ops->op_needs_rtnl ÐTOOL_OP_NEEDS_RTNL_RSS ; }return false; }
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +4 -0
@@ -5729,6 +5729,10 @@ const struct ethtool_ops bnxt_ethtool_ops = { .rxfh_max_num_contexts = BNXT_MAX_ETH_RSS_CTX + 1, .rxfh_indir_space = BNXT_MAX_RSS_TABLE_ENTRIES_P5, .rxfh_priv_size = sizeof(struct bnxt_rss_ctx), + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | +ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM | +ETHTOOL_OP_NEEDS_RTNL_SCOALESCE | + ETHTOOL_OP_NEEDS_RTNL_RSS, .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS_IRQ |
drivers/net/ethernet/google/gve/gve_ethtool.c +2 -0
@@ -983,6 +983,8 @@ const struct ethtool_ops gve_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS, .supported_ring_params =ETHTOOL_RING_USE_TCP_DATA_SPLIT | ETHTOOL_RING_USE_RX_BUF_LEN, + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | + ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM, .get_drvinfo = gve_get_drvinfo, .get_strings = gve_get_strings, .get_sset_count = gve_get_sset_count,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +3 -0
@@ -2719,6 +2719,9 @@ const struct ethtool_ops mlx5e_ethtool_ops = { .rxfh_per_ctx_fields = true, .rxfh_per_ctx_key = true, .rxfh_max_num_contexts = MLX5E_MAX_NUM_RSS, + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | +ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM | + ETHTOOL_OP_NEEDS_RTNL_SPFLAGS, .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USE_ADAPTIVE |
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -0
@@ -418,6 +418,8 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USE_ADAPTIVE, + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | + ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM, .get_drvinfo = mlx5e_rep_get_drvinfo, .get_link = ethtool_op_get_link, .get_strings = mlx5e_rep_get_strings,
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c +2 -0
@@ -285,6 +285,8 @@ const struct ethtool_ops mlx5i_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USE_ADAPTIVE, + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | + ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM, .get_drvinfo = mlx5i_get_drvinfo, .get_strings = mlx5i_get_strings, .get_sset_count = mlx5i_get_sset_count,
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +4 -1
@@ -2021,7 +2021,10 @@ static const struct ethtool_ops fbnic_ethtool_ops = { ETHTOOL_RING_USE_HDS_THRS, .rxfh_max_num_contexts = FBNIC_RPC_RSS_TBL_COUNT, .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_LINKSETTINGS | - ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM, +ETHTOOL_OP_NEEDS_RTNL_GPAUSEPARAM | +ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | +ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM | + ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM, .get_drvinfo = fbnic_get_drvinfo, .get_regs_len = fbnic_get_regs_len, .get_regs = fbnic_get_regs,
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +2 -0
@@ -575,6 +575,8 @@ static int mana_get_link_ksettings(struct net_device *ndev,const struct ethtool_ops mana_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_RX_CQE_FRAMES , + .op_needs_rtnl =ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | +ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM , .get_ethtool_stats = mana_get_ethtool_stats, .get_sset_count = mana_get_sset_count, .get_strings = mana_get_strings,
drivers/net/netdevsim/ethtool.c +1 -0
@@ -209,6 +209,7 @@ static const struct ethtool_ops nsim_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_ALL_PARAMS, .supported_ring_params =ETHTOOL_RING_USE_TCP_DATA_SPLIT | ETHTOOL_RING_USE_HDS_THRS, + .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS, .get_pause_stats = nsim_get_pause_stats, .get_pauseparam = nsim_get_pauseparam, .set_pauseparam = nsim_set_pauseparam,
net/ethtool/netlink.c +7 -2
@@ -903,6 +903,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)const u8 cmd = info->genlhdr->cmd;struct ethnl_req_info *req_info;struct net_device *dev; +bool need_rtnl;int ret; ops = ethnl_default_requests[cmd];
@@ -927,8 +928,11 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info) } dev = req_info->dev; + need_rtnl = !netdev_need_ops_lock (dev) || +ethtool_nl_msg_needs_rtnl (dev, cmd); -rtnl_lock (); +if (need_rtnl) +rtnl_lock ();netdev_lock_ops (dev); dev->cfg_pending =kmemdup (dev->cfg,sizeof (*dev->cfg),GFP_KERNEL_ACCOUNT );
@@ -958,7 +962,8 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info) out_tie_cfg: dev->cfg_pending = dev->cfg;netdev_unlock_ops (dev); -rtnl_unlock (); +if (need_rtnl) +rtnl_unlock (); out_dev:ethnl_parse_header_dev_put (req_info); out_free_req:
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 8/14 net: ethtool: optionally skip rtnl_lock in cable test handlers
In reply to Jakub KicinskiSkip rtnl_lock in cable test handlers. This is really a noop since no ops locked device supports these.
--- net/ethtool/cabletest.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
net/ethtool/cabletest.c +4 -8
@@ -73,8 +73,7 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) dev = req_info.dev; -rtnl_lock (); -netdev_lock_ops (dev); +netdev_lock_ops_compat (dev); phydev =ethnl_req_get_phydev (&req_info, tb,ETHTOOL_A_CABLE_TEST_HEADER , info->extack);
@@ -101,8 +100,7 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)ethnl_cable_test_started (phydev,ETHTOOL_MSG_CABLE_TEST_NTF ); out_unlock: -netdev_unlock_ops (dev); -rtnl_unlock (); +netdev_unlock_ops_compat (dev);ethnl_parse_header_dev_put (&req_info);return ret; }
@@ -342,8 +340,7 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info)if (ret) goto out_dev_put; -rtnl_lock (); -netdev_lock_ops (dev); +netdev_lock_ops_compat (dev); phydev =ethnl_req_get_phydev (&req_info, tb,ETHTOOL_A_CABLE_TEST_TDR_HEADER , info->extack);
@@ -371,8 +368,7 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info) ETHTOOL_MSG_CABLE_TEST_TDR_NTF); out_unlock: -netdev_unlock_ops (dev); -rtnl_unlock (); +netdev_unlock_ops_compat (dev); out_dev_put:ethnl_parse_header_dev_put (&req_info);return ret;
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 9/14 net: ethtool: optionally skip rtnl_lock in ethnl_tsinfo_dumpit()
In reply to Jakub Kicinskiethnl_tsinfo_dumpit() iterates netdevs and per-netdev PHY topology calling ops->get_ts_info(). Switch to the "ops compat locking" helpers which take either rtnl_lock or instance lock, depending on what the device needs.
--- net/ethtool/tsinfo.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
net/ethtool/tsinfo.c +15 -17
@@ -6,6 +6,7 @@#include <linux/ptp_clock_kernel.h> #include <net/netdev_lock.h> +#include "../core/dev.h" #include "bitset.h" #include "common.h" #include "netlink.h"
@@ -473,28 +474,25 @@ int ethnl_tsinfo_dumpit(struct sk_buff *skb, struct netlink_callback *cb) {struct ethnl_tsinfo_dump_ctx *ctx = (void *)cb->ctx;struct net *net =sock_net (skb->sk); -struct net_device *dev;int ret =0 ; -rtnl_lock ();if (ctx->req_info->base.dev) { - dev = ctx->req_info->base.dev; -netdev_lock_ops (dev); +struct net_device *dev = ctx->req_info->base.dev; + +netdev_lock_ops_compat (dev); ret =ethnl_tsinfo_dump_one_net_topo (skb, dev, cb); -netdev_unlock_ops (dev); - }else { -for_each_netdev_dump (net, dev, ctx->pos_ifindex) { -netdev_lock_ops (dev); - ret =ethnl_tsinfo_dump_one_net_topo (skb, dev, cb); -netdev_unlock_ops (dev); -if (ret <0 && ret != -EOPNOTSUPP ) -break ; - ctx->pos_phyindex =0 ; - ctx->netdev_dump_done = false; - ctx->pos_phcqualifier =HWTSTAMP_PROVIDER_QUALIFIER_PRECISE ; - } +netdev_unlock_ops_compat (dev); +return ret; + } + +for_each_netdev_lock_ops_compat_scoped (net, dev, ctx->pos_ifindex) { + ret =ethnl_tsinfo_dump_one_net_topo (skb, dev, cb); +if (ret <0 && ret != -EOPNOTSUPP ) +break ; + ctx->pos_phyindex =0 ; + ctx->netdev_dump_done = false; + ctx->pos_phcqualifier =HWTSTAMP_PROVIDER_QUALIFIER_PRECISE ; } -rtnl_unlock ();return ret; }
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 10/14 net: ethtool: optionally skip rtnl_lock in ethnl_act_module_fw_flash()
In reply to Jakub KicinskiModule firmware flashing reads SFF-8024 identifier bytes via .get_module_eeprom_by_page(). Other than that it modifies a bit in the netdev->ethtool struct. Both should be ops-locked at this point.
--- include/linux/netdevice.h | 2 +- net/ethtool/module.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
include/linux/netdevice.h +1 -1
@@ -2585,7 +2585,7 @@ struct net_device {* @up, @moving_ns, @nd_net, @xdp_features * * Ops protects: -* @cfg, @cfg_pending, @hwprov +* @cfg, @cfg_pending, @ethtool, @hwprov * * Double ops protects: * @real_num_rx_queues, @real_num_tx_queues
net/ethtool/module.c +2 -4
@@ -429,8 +429,7 @@ int ethnl_act_module_fw_flash(struct sk_buff *skb, struct genl_info *info)return ret; dev = req_info.dev; -rtnl_lock (); -netdev_lock_ops (dev); +netdev_lock_ops_compat (dev); ret =ethnl_ops_begin (dev);if (ret <0 ) goto out_unlock;
@@ -445,8 +444,7 @@ int ethnl_act_module_fw_flash(struct sk_buff *skb, struct genl_info *info)ethnl_ops_complete (dev); out_unlock: -netdev_unlock_ops (dev); -rtnl_unlock (); +netdev_unlock_ops_compat (dev);ethnl_parse_header_dev_put (&req_info);return ret; }
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 11/14 net: ethtool: optionally skip rtnl_lock in RSS context handlers
In reply to Jakub KicinskiSkip rtnl_lock in RSS context handlers if device is ops-locked. Fairly trivial conversion. bnxt needed rtnl_lock for changing the main context but looks like additional contexts are fine without it.
Note (for review bots?) that ethnl_ops_begin() checks whether the device is still registered.
--- net/ethtool/rss.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
net/ethtool/rss.c +6 -14
@@ -2,6 +2,7 @@#include <net/netdev_lock.h> +#include "../core/dev.h" #include "common.h" #include "netlink.h"
@@ -468,21 +469,16 @@ int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb) {struct rss_nl_dump_ctx *ctx =rss_dump_ctx (cb);struct net *net =sock_net (skb->sk); -struct net_device *dev;int ret =0 ; -rtnl_lock (); -for_each_netdev_dump (net, dev, ctx->ifindex) { +for_each_netdev_lock_ops_compat_scoped (net, dev, ctx->ifindex) {if (ctx->match_ifindex && ctx->match_ifindex != ctx->ifindex)break ; -netdev_lock_ops (dev); ret =rss_dump_one_dev (skb, cb, dev); -netdev_unlock_ops (dev);if (ret)break ; } -rtnl_unlock ();return ret; }
@@ -1037,8 +1033,7 @@ int ethnl_rss_create_doit(struct sk_buff *skb, struct genl_info *info)if (ret) goto exit_free_dev; -rtnl_lock (); -netdev_lock_ops (dev); +netdev_lock_ops_compat (dev); ret =ethnl_ops_begin (dev);if (ret <0 )
@@ -1125,8 +1120,7 @@ int ethnl_rss_create_doit(struct sk_buff *skb, struct genl_info *info) exit_ops:ethnl_ops_complete (dev); exit_dev_unlock: -netdev_unlock_ops (dev); -rtnl_unlock (); +netdev_unlock_ops_compat (dev); exit_free_dev:ethnl_parse_header_dev_put (&req.base); exit_free_rsp:
@@ -1179,8 +1173,7 @@ int ethnl_rss_delete_doit(struct sk_buff *skb, struct genl_info *info) goto exit_free_dev; } -rtnl_lock (); -netdev_lock_ops (dev); +netdev_lock_ops_compat (dev); ret =ethnl_ops_begin (dev);if (ret <0 )
@@ -1210,8 +1203,7 @@ int ethnl_rss_delete_doit(struct sk_buff *skb, struct genl_info *info)mutex_unlock (&dev->ethtool->rss_lock);ethnl_ops_complete (dev); exit_dev_unlock: -netdev_unlock_ops (dev); -rtnl_unlock (); +netdev_unlock_ops_compat (dev); exit_free_dev:ethnl_parse_header_dev_put (&req);return ret;
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 12/14 net: ethtool: ioctl: concentrate the locking
In reply to Jakub KicinskiAdd another layer of helper functions to make upcoming locking changes easier. Otherwise we'd need a pretty complex goto structure. netdev instance lock is now taken slightly sooner but that should not be an issue since rtnl_lock is already held, anyway.
--- net/ethtool/ioctl.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
net/ethtool/ioctl.c +25 -10
@@ -3257,18 +3257,14 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)/* The main entry point in this file. Called from net/core/dev_ioctl.c */ static int -__dev_ethtool (struct net *net,struct ifreq *ifr,void __user *useraddr, -u32 ethcmd,struct ethtool_devlink_compat *devlink_state) +dev_ethtool_locked (struct net *net,struct net_device *dev, +void __user *useraddr, +u32 ethcmd,struct ethtool_devlink_compat *devlink_state) { -struct net_device *dev;u32 sub_cmd;int rc;netdev_features_t old_features; - dev =__dev_get_by_name (net, ifr->ifr_name); -if (!dev) -return -ENODEV ; -if (ethcmd ==ETHTOOL_PERQUEUE ) {if (copy_from_user (&sub_cmd, useraddr +sizeof (ethcmd),sizeof (sub_cmd)))return -EFAULT ;
@@ -3319,7 +3315,6 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,return -EPERM ; } -netdev_lock_ops (dev);if (dev->dev.parent)pm_runtime_get_sync (dev->dev.parent);
@@ -3559,7 +3554,29 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr, out:if (dev->dev.parent)pm_runtime_put (dev->dev.parent); + +return rc; +} + +static int +__dev_ethtool (struct net *net,struct ifreq *ifr,void __user *useraddr, +u32 ethcmd,struct ethtool_devlink_compat *devlink_state) +{ +struct net_device *dev; +int rc; + +rtnl_lock (); + dev =__dev_get_by_name (net, ifr->ifr_name); +if (!dev) { + rc = -ENODEV ; + goto exit_rtnl_unlock; + } + +netdev_lock_ops (dev); + rc =dev_ethtool_locked (net, dev, useraddr, ethcmd, devlink_state);netdev_unlock_ops (dev); +exit_rtnl_unlock: +rtnl_unlock ();return rc; }
@@ -3587,9 +3604,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr)break ; } -rtnl_lock (); rc =__dev_ethtool (net, ifr, useraddr, ethcmd, state); -rtnl_unlock ();if (rc) goto exit_free;
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerPATCH 13/14 net: ethtool: optionally skip rtnl_lock on IOCTL path
In reply to Jakub KicinskiConvert the IOCTL path similarly to how we converted Netlink. The device lookup gets a little hairy. We could take rtnl_lock unconditionally and drop it before calling the driver (this would avoid the reference + liveness check). But I think being able to make progress even if rtnl is dead-locked is quite useful.
First extra concern is handling features. List all the cmds which modify features and always take rtnl_lock. We could fold this list into ethtool_ioctl_needs_rtnl() but seems cleaner to keep ethtool_ioctl_needs_rtnl() driver-related. If a driver changed features and we were not holding rtnl_lock - warn about it. It can only happen on buggy ops locked drivers (buggy because they should have set appropriate "I need rtnl for op X" bit).
Second wrinkle is the PHY ID hack which drops the locks while sleeping. Convert its static "busy" variable which used to be protected by rtnl_lock to a field in struct ethtool_netdev_state. This feature is about identifying an adapter or a port within a system, so being able to blink multiple LEDs at the same time is likely not very useful in practice. But it's the simplest fix, we can add a mutex if someone thinks a system should only be ID'ing one port at a time.
--- include/linux/ethtool.h | 2 + net/ethtool/ioctl.c | 98 ++++++++++++++++++++++++++++++----------- 2 files changed, 74 insertions(+), 26 deletions(-)
include/linux/ethtool.h +2 -0
@@ -1375,6 +1375,7 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,* within RTNL. * @rss_indir_user_size: Number of user provided entries for the default * (context 0) indirection table. +* @phys_id_busy: Loop blinking the device LED is running. * @wol_enabled: Wake-on-LAN is enabled * @module_fw_flash_in_progress: Module firmware flashing is in progress. */
@@ -1382,6 +1383,7 @@ struct ethtool_netdev_state {struct xarray rss_ctx;struct mutex rss_lock;u32 rss_indir_user_size; + unsigned phys_id_busy:1; unsigned wol_enabled:1; unsigned module_fw_flash_in_progress:1; };
net/ethtool/ioctl.c +72 -26
205 lines not on this page · raw message
Signature · 1 line
2.54.0
Re: [PATCH net-next 13/14] net: ethtool: optionally skip rtnl_lock on IOCTL path
Quoted 213 lines · Jakub Kicinski
Convert the IOCTL path similarly to how we converted Netlink. The device lookup gets a little hairy. We could take
rtnl_lockunconditionally and drop it before calling the driver (this would avoid the reference + liveness check). But I think being able to make progress even if rtnl is dead-locked is quite useful.First extra concern is handling features. List all the cmds which modify features and always take
rtnl_lock. We could fold this list intoethtool_ioctl_needs_rtnl()but seems cleaner to keepethtool_ioctl_needs_rtnl()driver-related. If a driver changed features and we were not holdingrtnl_lock- warn about it. It can only happen on buggy ops locked drivers (buggy because they should have set appropriate "I need rtnl for op X" bit).Second wrinkle is the PHY ID hack which drops the locks while sleeping. Convert its static "busy" variable which used to be protected by
rtnl_lockto a field in structethtool_netdev_state. This feature is about identifying an adapter or a port within a system, so being able to blink multiple LEDs at the same time is likely not very useful in practice. But it's the simplest fix, we can add a mutex if someone thinks a system should only be ID'ing one port at a time.Signed-off-by Jakub Kicinski <[email protected]>--- include/linux/ethtool.h | 2 + net/ethtool/ioctl.c | 98 ++++++++++++++++++++++++++++++----------- 2 files changed, 74 insertions(+), 26 deletions(-)include/linux/ethtool.h +2
-0@@ -1375,6 +1375,7 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,* within RTNL. * @rss_indir_user_size: Number of user provided entries for the default * (context 0) indirection table. +* @phys_id_busy: Loop blinking the device LED is running. * @wol_enabled: Wake-on-LAN is enabled * @module_fw_flash_in_progress: Module firmware flashing is in progress. */ @@ -1382,6 +1383,7 @@ struct ethtool_netdev_state {struct xarray rss_ctx;struct mutex rss_lock;u32 rss_indir_user_size; + unsigned phys_id_busy:1; unsigned wol_enabled:1; unsigned module_fw_flash_in_progress:1; };net/ethtool/ioctl.c +36
-18@@ -543,7 +543,7 @@ static int ethtool_get_link_ksettings(struct net_device *dev,int err =0 ;struct ethtool_link_ksettings link_ksettings; -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (!dev->ethtool_ops->get_link_ksettings)return -EOPNOTSUPP ;@@ -600,7 +600,7 @@ static int ethtool_set_link_ksettings(struct net_device *dev,struct ethtool_link_ksettings link_ksettings = {};int err; -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (!dev->ethtool_ops->set_link_ksettings)return -EOPNOTSUPP ;@@ -674,7 +674,7 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)struct ethtool_cmd cmd;int err; -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (!dev->ethtool_ops->get_link_ksettings)return -EOPNOTSUPP ;@@ -710,7 +710,7 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)struct ethtool_cmd cmd;int ret; -ASSERT_RTNL (); +netdev_ops_assert_locked (dev);if (copy_from_user (&cmd, useraddr,sizeof (cmd)))return -EFAULT ;@@ -2451,10 +2451,10 @@ void ethtool_puts(u8 **data, const char *str) }EXPORT_SYMBOL (ethtool_puts); -static int ethtool_phys_id (struct net_device *dev,void __user *useraddr) +static int ethtool_phys_id (struct net_device *dev,void __user *useraddr, +bool has_rtnl_lock) {struct ethtool_value id; -static bool busy;const struct ethtool_ops *ops = dev->ethtool_ops;netdevice_tracker dev_tracker;int rc;@@ -2462,7 +2462,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)if (!ops->set_phys_id)return -EOPNOTSUPP ; -if (busy) +if (dev->ethtool->phys_id_busy)return -EBUSY ;if (copy_from_user (&id, useraddr,sizeof (id)))@@ -2472,13 +2472,14 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)if (rc <0 )return rc; -/* Drop the RTNL lock while waiting, but prevent reentry or +/* Drop the locks while waiting, but prevent reentry or * removal of the device. */ - busy = true; + dev->ethtool->phys_id_busy = true;netdev_hold (dev, &dev_tracker,GFP_KERNEL );netdev_unlock_ops (dev); -rtnl_unlock (); +if (has_rtnl_lock) +rtnl_unlock ();if (rc ==0 ) {/* Driver will handle this itself */ @@ -2491,22 +2492,25 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)u64 i =0 ;do { -rtnl_lock (); +if (has_rtnl_lock) +rtnl_lock ();netdev_lock_ops (dev); rc = ops->set_phys_id (dev, (i++ &1 ) ?ETHTOOL_ID_OFF :ETHTOOL_ID_ON );netdev_unlock_ops (dev); -rtnl_unlock (); +if (has_rtnl_lock) +rtnl_unlock ();if (rc)break ;schedule_timeout_interruptible (interval); }while (!signal_pending (current) && (!id.data || i < count)); } -rtnl_lock (); +if (has_rtnl_lock) +rtnl_lock ();netdev_lock_ops (dev);netdev_put (dev, &dev_tracker); - busy = false; + dev->ethtool->phys_id_busy = false; (void ) ops->set_phys_id (dev,ETHTOOL_ID_INACTIVE );return rc;@@ -3259,7 +3263,8 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)static int dev_ethtool_locked (struct net *net,struct net_device *dev,void __user *useraddr, -u32 ethcmd,struct ethtool_devlink_compat *devlink_state) +u32 ethcmd,struct ethtool_devlink_compat *devlink_state, +bool has_rtnl_lock) {u32 sub_cmd;int rc;@@ -3315,6 +3320,8 @@ dev_ethtool_locked(struct net *net, struct net_device *dev,return -EPERM ; } +netdev_ops_assert_locked (dev); +if (dev->dev.parent)pm_runtime_get_sync (dev->dev.parent);@@ -3402,7 +3409,7 @@ dev_ethtool_locked(struct net *net, struct net_device *dev, rc =ethtool_get_strings (dev, useraddr);break ;case ETHTOOL_PHYS_ID : - rc =ethtool_phys_id (dev, useraddr); + rc =ethtool_phys_id (dev, useraddr, has_rtnl_lock);break ;case ETHTOOL_GSTATS : rc =ethtool_get_stats (dev, useraddr);@@ -3549,8 +3556,12 @@ dev_ethtool_locked(struct net *net, struct net_device *dev,if (dev->ethtool_ops->complete) dev->ethtool_ops->complete (dev); -if (old_features != dev->features) -netdev_features_change (dev); +if (old_features != dev->features) { +if (has_rtnl_lock) +netdev_features_change (dev); +else +netdev_WARN (dev,"unexpected device features change with ethtool cmd %u" , ethcmd); + } out:if (dev->dev.parent)pm_runtime_put (dev->dev.parent);@@ -3558,25 +3569,60 @@ dev_ethtool_locked(struct net *net, struct net_device *dev,return rc; } +/* Commands that may toggle dev->features in net/ethtool/ioctl.c and so +* call into __netdev_update_features(), which still requires rtnl_lock. +* Driver-decided SET commands that may chain into rtnl-only helpers are +* covered by ethtool_ioctl_needs_rtnl()/ETHTOOL_OP_NEEDS_RTNL_*. +*/ +static bool ethtool_cmd_changes_features (u32 ethcmd) +{
net/ethtool/ioctl.c dev_ethtool_locked(struct net *net, struct net_device *dev, · line 3588
Quoted 10 lines
net/ethtool/ioctl.c +10
-0+switch (ethcmd) { +case ETHTOOL_SFEATURES : +case ETHTOOL_SFLAGS : +case ETHTOOL_STXCSUM : +case ETHTOOL_SRXCSUM : +case ETHTOOL_SSG : +case ETHTOOL_STSO : +case ETHTOOL_SGSO : +case ETHTOOL_SGRO : +return true;
GVE's gve_get_ethtool_stats (ETHTOOL_GSTATS) still has ASSERT_RTNL and is now reachable with only ops lock?
Jakub Kicinski
maintainerRe: [PATCH net-next 13/14] net: ethtool: optionally skip rtnl_lock on IOCTL path
Quoted 2 lines · On Mon, 1 Jun 2026 08:17:56 -0700 Stanislav Fomichev wrote:
GVE's
gve_get_ethtool_stats(ETHTOOL_GSTATS) still hasASSERT_RTNLand is now reachable with only ops lock?
Good catch, thanks! I'll just delete it, we could switch it to netdev_assert_locked() but TBH seems like a rather arbitrary place to add such an assert in the first place.
Jakub Kicinski
maintainerPATCH 14/14 docs: net: ethtool: document ops-locked drivers and op_needs_rtnl
In reply to Jakub KicinskiCatch up various bits of documentation after the locking changes.
--- Documentation/networking/netdev-features.rst | 7 +++++++ Documentation/networking/netdevices.rst | 17 ++++++++++------- include/linux/ethtool.h | 10 ++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-)
Documentation/networking/netdev-features.rst +7 -0
@@ -76,6 +76,13 @@ netdev instance lock, that lock must be held as well. This should not be done from ndo_*_features callbacks. netdev->features should not be modified by driver except by means of ndo_fix_features callback. +For "ops locked" drivers (see Documentation/networking/netdevices.rst), +ethtool callbacks that may end up invoking netdev_update_features() must +opt back into rtnl_lock by setting the matching ETHTOOL_OP_NEEDS_RTNL_* +bit in ``ethtool_ops::op_needs_rtnl``. The ethtool core then keeps +rtnl_lock held across those SET callbacks so the contract above still +holds. + ndo_features_check is called for each skb before that skb is passed to ndo_start_xmit. Driver may perform any non-trivial checks (e.g. exact header geometry / length) and withdraw features like HW_CSUM or TSO,
Documentation/networking/netdevices.rst +10 -7
@@ -351,10 +351,6 @@ virtual and the physical device. To prevent deadlocks, the virtual device's lock must always be acquired before the physical device's (see ``netdev_nl_queue_create_doit``). -In the future, there will be an option for individual -drivers to opt out of using ``rtnl_lock`` and instead perform their control -operations directly under the netdev instance lock. - Device drivers are encouraged to rely on the instance lock where possible. For the (mostly software) drivers that need to interact with the core stack,
@@ -375,9 +371,16 @@ the instance lock. struct ethtool_ops ------------------ -Similarly to ``ndos`` the instance lock is only held for select drivers. -For "ops locked" drivers all ethtool ops without exceptions should -be called under the instance lock. +For non-"ops locked" drivers ethtool_ops are executed under ``rtnl_lock``. + +For "ops locked" drivers ``ethtool_ops``, unlike ``ndos``, run under +the instance lock **only**. Driver may request that ``rtnl_lock`` +is held around specific operations (both SET and GET) by setting +appropriate bits in ``ethtool_ops::op_needs_rtnl`` (if necessary +``ETHTOOL_OP_NEEDS_RTNL_*`` bit doesn't exist just add it). Commonly +used core helpers which force drivers to selectively opt-in to +``rtnl_lock`` protection include ``netdev_update_features()``, +``netif_set_real_num_*_queues()``, and phylink helpers. struct netdev_stat_ops ----------------------
include/linux/ethtool.h +8 -2
@@ -1177,8 +1177,14 @@ struct kernel_ethtool_ts_info {* @get_mm_stats: Query the 802.3 MAC Merge layer statistics. * * All operations are optional (i.e. the function pointer may be set -* to %NULL) and callers must take this into account. Callers must -* hold the RTNL lock or netdev instance lock (see @op_needs_rtnl). +* to %NULL) and callers must take this into account. +* +* For traditional drivers callers hold ``rtnl_lock`` across the call. +* For "ops locked" drivers (see Documentation/networking/netdevices.rst) +* callers instead hold the netdev instance lock (``netdev_lock_ops``); +* ``rtnl_lock`` is additionally held only for callbacks for which +* the driver opts in via the matching ``ETHTOOL_OP_NEEDS_RTNL_*`` bit +* in @op_needs_rtnl. * * See the structures used by these operations for further documentation. * Note that for all operations using a structure ending with a zero-
Signature · 1 line
2.54.0
Re: [PATCH net-next 14/14] docs: net: ethtool: document ops-locked drivers and op_needs_rtnl
Hi Jakub
Documentation/networking/netdev-features.rst
Quoted 13 lines · Jakub Kicinski
Catch up various bits of documentation after the locking changes.
Signed-off-by Jakub Kicinski <[email protected]>--- Documentation/networking/netdev-features.rst | 7 +++++++ Documentation/networking/netdevices.rst | 17 ++++++++++------- include/linux/ethtool.h | 10 ++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-)Documentation/networking/netdev-features.rst +0
-0
Thanks
Nicolai
syzbot ci has tested the following series
syzbot ci has tested the following series
[v1] net: ethtool: let ops locked drivers run without rtnl_lock
https://lore.kernel.org/all/[email protected]
* [PATCH net-next 01/14] net: ethtool: cmis_cdb: hold instance lock for ops locked devices
* [PATCH net-next 02/14] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked
* [PATCH net-next 03/14] net: ethtool: serialize broadcast notification sequence allocation
* [PATCH net-next 04/14] net: ethtool: relax ethnl_req_get_phydev() locking assertion
* [PATCH net-next 05/14] net: ethtool: make dev->hwprov ops-protected
* [PATCH net-next 06/14] net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops
* [PATCH net-next 07/14] net: ethtool: optionally skip rtnl_lock on Netlink path for SET ops
* [PATCH net-next 08/14] net: ethtool: optionally skip rtnl_lock in cable test handlers
* [PATCH net-next 09/14] net: ethtool: optionally skip rtnl_lock in ethnl_tsinfo_dumpit()
* [PATCH net-next 10/14] net: ethtool: optionally skip rtnl_lock in ethnl_act_module_fw_flash()
* [PATCH net-next 11/14] net: ethtool: optionally skip rtnl_lock in RSS context handlers
* [PATCH net-next 12/14] net: ethtool: ioctl: concentrate the locking
* [PATCH net-next 13/14] net: ethtool: optionally skip rtnl_lock on IOCTL path
* [PATCH net-next 14/14] docs: net: ethtool: document ops-locked drivers and op_needs_rtnl
and found the following issue:
possible deadlock in __ethtool_get_link_ksettings
Full report is available here:
https://ci.syzbot.org/series/ada8852f-9efd-4b85-87aa-2f5d8fe16040
***
possible deadlock in __ethtool_get_link_ksettings
tree: net-next URL: https://kernel.googlesource.com/pub/scm/linux/kernel/git/netdev/net-next.git base: 9a82e387e27a4422a0d2d9d644180b7bd913e85a arch: amd64 compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8 config: https://ci.syzbot.org/builds/2968208d-6483-4d38-be45-de68d3b94775/config syz repro: https://ci.syzbot.org/findings/d8670aa1-9241-49be-8108-cdbed56dd4a5/syz_repro
dummy0: entered promiscuous mode
bridge0: port 3(dummy0) entered blocking state
bridge0: port 3(dummy0) entered forwarding state
============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.1.28/5852 is trying to acquire lock:ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock include/linux/netdevice.h:2833 [inline] ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock_ops include/net/netdev_lock.h:42 [inline] ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: __ethtool_get_link_ksettings+0x12b/0x290 net/ethtool/ioctl.c:462
but task is already holding lock:ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock include/linux/netdevice.h:2833 [inline] ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock_ops include/net/netdev_lock.h:42 [inline] ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: do_setlink+0x3d2/0x45a0 net/core/rtnetlink.c:3117 and the lock comparison function returns 0:
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&dev_instance_lock_key#3);
lock(&dev_instance_lock_key#3);
*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by syz.1.28/5852:
#0: ffffffff8fdd2d80 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline]
#0: ffffffff8fdd2d80 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_nets_lock net/core/rtnetlink.c:341 [inline] #0: ffffffff8fdd2d80 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_setlink+0x6bb/0xb40 net/core/rtnetlink.c:3527 #1: ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock include/linux/netdevice.h:2833 [inline] #1: ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: netdev_lock_ops include/net/netdev_lock.h:42 [inline] #1: ffff888115f78dc8 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: do_setlink+0x3d2/0x45a0 net/core/rtnetlink.c:3117
stack backtrace: CPU: 0 UID: 0 PID: 5852 Comm: syz.1.28 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_deadlock_bug+0x279/0x290 kernel/locking/lockdep.c:3041 check_deadlock kernel/locking/lockdep.c:3093 [inline] validate_chain kernel/locking/lockdep.c:3895 [inline] __lock_acquire+0x253f/0x2cf0 kernel/locking/lockdep.c:5237 lock_acquire+0x106/0x350 kernel/locking/lockdep.c:5868 __mutex_lock_common kernel/locking/mutex.c:646 [inline] __mutex_lock+0x1a3/0x1550 kernel/locking/mutex.c:820 netdev_lock include/linux/netdevice.h:2833 [inline] netdev_lock_ops include/net/netdev_lock.h:42 [inline] __ethtool_get_link_ksettings+0x12b/0x290 net/ethtool/ioctl.c:462 port_cost+0xc0/0x3a0 net/bridge/br_if.c:39 br_port_carrier_check+0x12d/0x3f0 net/bridge/br_if.c:80 br_device_event+0x65c/0x970 net/bridge/br.c:101 notifier_call_chain+0x1ad/0x3d0 kernel/notifier.c:85 __dev_notify_flags+0x248/0x310 net/core/dev.c:9804 netif_change_flags+0xe8/0x1a0 net/core/dev.c:9819 do_setlink+0xfa5/0x45a0 net/core/rtnetlink.c:3207 rtnl_setlink+0x792/0xb40 net/core/rtnetlink.c:3537 rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:7062 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2556 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x75c/0x8e0 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1900 sock_sendmsg_nosec net/socket.c:787 [inline] __sock_sendmsg net/socket.c:802 [inline] ____sys_sendmsg+0x972/0x9f0 net/socket.c:2698 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2752 __sys_sendmsg net/socket.c:2784 [inline] __do_sys_sendmsg net/socket.c:2789 [inline] __se_sys_sendmsg net/socket.c:2787 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2787 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f087ad9ce59 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f087bc25028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f087b015fa0 RCX: 00007f087ad9ce59 RDX: 0000000000000000 RSI: 0000200000000040 RDI: 0000000000000004 RBP: 00007f087ae32d6f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f087b016038 R14: 00007f087b015fa0 R15: 00007ffcefdf0348 </TASK>
***
If these findings have caused you to resend the series or submit a separate fix, please add the following tag to your commit message:
---
This report is generated by a bot. It may contain errors. syzbot ci engineers can be reached at [email protected].
To test a patch for this bug, please reply with #syz test (should be on a separate line).
The patch should be attached to the email.
Note: arguments like custom git repos and branches are not supported.