]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ppp: require callers of ppp_dev_name() to hold RCU
authorQingfang Deng <dqfext@gmail.com>
Mon, 16 Mar 2026 09:28:23 +0000 (17:28 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 17 Mar 2026 23:18:48 +0000 (16:18 -0700)
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>
Reviewed-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260316092824.479149-1-dqfext@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ppp/ppp_generic.c
include/linux/ppp_channel.h

index a036ddfe327b96bdf9cec9fa3f85a37cab8fce1a..cb29a6968c6332263c58c52dcd0f9c02b5f396c9 100644 (file)
@@ -2969,6 +2969,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)
 {
@@ -2977,11 +2978,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;
 }
index ca8ad03eeef0f63d378cdd914dfe0dc18c387735..2f63e9a6cc88984c075792dcbd6c832ff45acd51 100644 (file)
@@ -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 *);
 
 /*