* [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU
@ 2026-03-16 9:28 Qingfang Deng
2026-03-17 20:05 ` Breno Leitao
2026-03-17 23:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Qingfang Deng @ 2026-03-16 9:28 UTC (permalink / raw)
To: linux-ppp, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Cc: James Chapman
ppp_dev_name() holds the RCU read lock internally to protect pch->ppp.
However, as it returns netdev->name to the caller, the caller should
also hold either RCU or RTNL lock to prevent the netdev from being
freed.
The only two references of the function is in the L2TP driver, both of
which already hold RCU. So remove the internal RCU lock and document
that callers must hold RCU.
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
---
drivers/net/ppp/ppp_generic.c | 3 +--
include/linux/ppp_channel.h | 4 +++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 6344c5eb0f98..0918ece061eb 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2995,6 +2995,7 @@ int ppp_unit_number(struct ppp_channel *chan)
/*
* Return the PPP device interface name of a channel.
+ * Caller must hold RCU read lock.
*/
char *ppp_dev_name(struct ppp_channel *chan)
{
@@ -3003,11 +3004,9 @@ char *ppp_dev_name(struct ppp_channel *chan)
struct ppp *ppp;
if (pch) {
- rcu_read_lock();
ppp = rcu_dereference(pch->ppp);
if (ppp && ppp->dev)
name = ppp->dev->name;
- rcu_read_unlock();
}
return name;
}
diff --git a/include/linux/ppp_channel.h b/include/linux/ppp_channel.h
index ca8ad03eeef0..2f63e9a6cc88 100644
--- a/include/linux/ppp_channel.h
+++ b/include/linux/ppp_channel.h
@@ -72,7 +72,9 @@ extern int ppp_channel_index(struct ppp_channel *);
/* Get the unit number associated with a channel, or -1 if none */
extern int ppp_unit_number(struct ppp_channel *);
-/* Get the device name associated with a channel, or NULL if none */
+/* Get the device name associated with a channel, or NULL if none.
+ * Caller must hold RCU read lock.
+ */
extern char *ppp_dev_name(struct ppp_channel *);
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU
2026-03-16 9:28 [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU Qingfang Deng
@ 2026-03-17 20:05 ` Breno Leitao
2026-03-17 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2026-03-17 20:05 UTC (permalink / raw)
To: Qingfang Deng
Cc: linux-ppp, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, James Chapman
On Mon, Mar 16, 2026 at 05:28:23PM +0800, Qingfang Deng wrote:
> ppp_dev_name() holds the RCU read lock internally to protect pch->ppp.
> However, as it returns netdev->name to the caller, the caller should
> also hold either RCU or RTNL lock to prevent the netdev from being
> freed.
>
> The only two references of the function is in the L2TP driver, both of
nit: The only two references of the function *are*...
> which already hold RCU. So remove the internal RCU lock and document
> that callers must hold RCU.
This symbol is also exported, but, we don't care if external drivers
call it without holding the RCU read lock.
> Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU
2026-03-16 9:28 [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU Qingfang Deng
2026-03-17 20:05 ` Breno Leitao
@ 2026-03-17 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-17 23:30 UTC (permalink / raw)
To: Qingfang Deng
Cc: linux-ppp, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, jchapman
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 16 Mar 2026 17:28:23 +0800 you wrote:
> ppp_dev_name() holds the RCU read lock internally to protect pch->ppp.
> However, as it returns netdev->name to the caller, the caller should
> also hold either RCU or RTNL lock to prevent the netdev from being
> freed.
>
> The only two references of the function is in the L2TP driver, both of
> which already hold RCU. So remove the internal RCU lock and document
> that callers must hold RCU.
>
> [...]
Here is the summary with links:
- [net-next] ppp: require callers of ppp_dev_name() to hold RCU
https://git.kernel.org/netdev/net-next/c/bb8539e0e609
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-17 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 9:28 [PATCH net-next] ppp: require callers of ppp_dev_name() to hold RCU Qingfang Deng
2026-03-17 20:05 ` Breno Leitao
2026-03-17 23:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox