Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

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>

authored by

Qingfang Deng and committed by
Jakub Kicinski
bb8539e0 e3f741f5

+4 -3
+1 -2
drivers/net/ppp/ppp_generic.c
··· 2969 2969 2970 2970 /* 2971 2971 * Return the PPP device interface name of a channel. 2972 + * Caller must hold RCU read lock. 2972 2973 */ 2973 2974 char *ppp_dev_name(struct ppp_channel *chan) 2974 2975 { ··· 2978 2977 struct ppp *ppp; 2979 2978 2980 2979 if (pch) { 2981 - rcu_read_lock(); 2982 2980 ppp = rcu_dereference(pch->ppp); 2983 2981 if (ppp && ppp->dev) 2984 2982 name = ppp->dev->name; 2985 - rcu_read_unlock(); 2986 2983 } 2987 2984 return name; 2988 2985 }
+3 -1
include/linux/ppp_channel.h
··· 72 72 /* Get the unit number associated with a channel, or -1 if none */ 73 73 extern int ppp_unit_number(struct ppp_channel *); 74 74 75 - /* Get the device name associated with a channel, or NULL if none */ 75 + /* Get the device name associated with a channel, or NULL if none. 76 + * Caller must hold RCU read lock. 77 + */ 76 78 extern char *ppp_dev_name(struct ppp_channel *); 77 79 78 80 /*