Skip to contentSkip to conversation

ppp: require callers of ppp_dev_name() to hold RCU

PATCH Applied Qingfang Deng 3 participants 3 messages Mar 16 – Mar 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppp: require callers of ppp_dev_name() to hold RCU

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.

---
 drivers/net/ppp/ppp_generic.c | 3 +--
 include/linux/ppp_channel.h   | 4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/ppp/ppp_generic.c +1 -2
index 6344c5eb0f98..0918ece061eb 100644
@@ -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;
 }
include/linux/ppp_channel.h +3 -1
index ca8ad03eeef0..2f63e9a6cc88 100644
@@ -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 *);
 
 /*
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Qingfang Deng

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*...

Quoted 2 lines

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.

Quoted 1 line
#2 lore raw
In reply to Qingfang Deng
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html