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.

netpoll: hold rcu read lock in __netpoll_send_skb()

The function __netpoll_send_skb() is being invoked without holding the
RCU read lock. This oversight triggers a warning message when
CONFIG_PROVE_RCU_LIST is enabled:

net/core/netpoll.c:330 suspicious rcu_dereference_check() usage!

netpoll_send_skb
netpoll_send_udp
write_ext_msg
console_flush_all
console_unlock
vprintk_emit

To prevent npinfo from disappearing unexpectedly, ensure that
__netpoll_send_skb() is protected with the RCU read lock.

Fixes: 2899656b494dcd1 ("netpoll: take rcu_read_lock_bh() in netpoll_send_skb_on_dev()")
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250306-netpoll_rcu_v2-v2-1-bc4f5c51742a@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Breno Leitao and committed by
Jakub Kicinski
505ead7a e6360f0d

+7 -2
+7 -2
net/core/netpoll.c
··· 319 319 static netdev_tx_t __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 320 320 { 321 321 netdev_tx_t status = NETDEV_TX_BUSY; 322 + netdev_tx_t ret = NET_XMIT_DROP; 322 323 struct net_device *dev; 323 324 unsigned long tries; 324 325 /* It is up to the caller to keep npinfo alive. */ ··· 328 327 lockdep_assert_irqs_disabled(); 329 328 330 329 dev = np->dev; 330 + rcu_read_lock(); 331 331 npinfo = rcu_dereference_bh(dev->npinfo); 332 332 333 333 if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) { 334 334 dev_kfree_skb_irq(skb); 335 - return NET_XMIT_DROP; 335 + goto out; 336 336 } 337 337 338 338 /* don't get messages out of order, and no recursion */ ··· 372 370 skb_queue_tail(&npinfo->txq, skb); 373 371 schedule_delayed_work(&npinfo->tx_work,0); 374 372 } 375 - return NETDEV_TX_OK; 373 + ret = NETDEV_TX_OK; 374 + out: 375 + rcu_read_unlock(); 376 + return ret; 376 377 } 377 378 378 379 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)