summaryrefslogtreecommitdiff
path: root/net/core/netpoll.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2020-08-26 22:40:06 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-12 12:47:40 +0300
commit6048d57b66d724a3aa0faf52bf3eb2126396450f (patch)
tree4aeed4a4693c3b5dd0a0fbd22bc8d162c4e8102a /net/core/netpoll.c
parent20e63db77149deb52d76ff9c8e7ddd3349c390ea (diff)
downloadlinux-6048d57b66d724a3aa0faf52bf3eb2126396450f.tar.xz
net: disable netpoll on fresh napis
[ Upstream commit 96e97bc07e90f175a8980a22827faf702ca4cb30 ] napi_disable() makes sure to set the NAPI_STATE_NPSVC bit to prevent netpoll from accessing rings before init is complete. However, the same is not done for fresh napi instances in netif_napi_add(), even though we expect NAPI instances to be added as disabled. This causes crashes during driver reconfiguration (enabling XDP, changing the channel count) - if there is any printk() after netif_napi_add() but before napi_enable(). To ensure memory ordering is correct we need to use RCU accessors. Reported-by: Rob Sherwood <rsher@fb.com> Fixes: 2d8bff12699a ("netpoll: Close race condition between poll_one_napi and napi_disable") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core/netpoll.c')
-rw-r--r--net/core/netpoll.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 5de180a9b7f5..9c1bad3909bd 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -178,7 +178,7 @@ static void poll_napi(struct net_device *dev)
{
struct napi_struct *napi;
- list_for_each_entry(napi, &dev->napi_list, dev_list) {
+ list_for_each_entry_rcu(napi, &dev->napi_list, dev_list) {
if (napi->poll_owner != smp_processor_id() &&
spin_trylock(&napi->poll_lock)) {
poll_one_napi(napi);