sfc: remove ASSERT_RTNL() from get_ts_info function
Subsystems (3)
PATCH 1/1 sfc: remove ASSERT_RTNL() from get_ts_info function
From: Mohammad Heib <[email protected]>
The SFC driver currently asserts that the RTNL lock is held in efx_ptp_get_ts_info() using ASSERT_RTNL(). While this is correct for the ethtool ioctl path, this function can also be called from the SO_TIMESTAMPING socket path where RTNL is not held, which triggers kernel BUGs in debug builds.
This patch removes the ASSERT_RTNL() to avoid these assertions in kernel logs when called from paths that do not hold RTNL.
--- drivers/net/ethernet/sfc/ptp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/sfc/ptp.c +0 -2
@@ -1864,8 +1864,6 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct kernel_ethtool_ts_info *ts_struct efx_ptp_data *ptp = efx->ptp_data;struct efx_nic *primary = efx->primary; -ASSERT_RTNL (); -if (!ptp)return ;
Signature · 1 line
2.50.1
Quoted 10 lines · On Mon, Aug 25, 2025 at 04:57:49PM +0300, [email protected] wrote:
From: Mohammad Heib <[email protected]>
The SFC driver currently asserts that the RTNL lock is held in
efx_ptp_get_ts_info()usingASSERT_RTNL(). While this is correct for the ethtool ioctl path, this function can also be called from theSO_TIMESTAMPINGsocket path where RTNL is not held, which triggers kernel BUGs in debug builds.This patch removes the
ASSERT_RTNL()to avoid these assertions in kernel logs when called from paths that do not hold RTNL.
What is missing from the commit message is an explanation of why RTNL does not need to be held in this function. Maybe this is a real bug and you are just hiding it, rather than fixing it?
Andrew
Hi Andrew,
Thanks for the feedback.
My initial version was actually to add rtnl_lock inside sock_set_timestamping since that function was added by this patch:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
without considering RTNL and the safety it provides.
I'm not that experienced with locking, and adding RTNL there felt like a risky change to me even though it's a control path so I was a bit hesitant to do it.
That's why I decided instead to send this patch that removes the assertion, mainly to get feedback and a heads-up from people with more experience in this area.
if you think it will be safe to add rtnl lock inside the sock_set_timestamping i can rework my change.
Quoted 17 lines · Andrew Lunn
Quoted 10 lines · On Mon, Aug 25, 2025 at 04:57:49PM +0300, [email protected] wrote:
From: Mohammad Heib <[email protected]>
The SFC driver currently asserts that the RTNL lock is held in
efx_ptp_get_ts_info()usingASSERT_RTNL(). While this is correct for the ethtool ioctl path, this function can also be called from theSO_TIMESTAMPINGsocket path where RTNL is not held, which triggers kernel BUGs in debug builds.This patch removes the
ASSERT_RTNL()to avoid these assertions in kernel logs when called from paths that do not hold RTNL.What is missing from the commit message is an explanation of why RTNL does not need to be held in this function. Maybe this is a real bug and you are just hiding it, rather than fixing it?
Andrew