net: make sure napi_list is safe for RCU traversal
authorJakub Kicinski <kuba@kernel.org>
Wed, 9 Sep 2020 17:37:53 +0000 (10:37 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Sep 2020 20:08:46 +0000 (13:08 -0700)
netpoll needs to traverse dev->napi_list under RCU, make
sure it uses the right iterator and that removal from this
list is handled safely.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c
net/core/netpoll.c

index e0a1be9868242a0ef5add51e30c98cdf3ae048e4..03624192862afce2c36e562fa0e985388fddcc14 100644 (file)
@@ -6656,7 +6656,7 @@ void __netif_napi_del(struct napi_struct *napi)
                return;
 
        napi_hash_del(napi);
-       list_del_init(&napi->dev_list);
+       list_del_rcu(&napi->dev_list);
        napi_free_frags(napi);
 
        flush_gro_hash(napi);
index 2338753e936b7188d7d0ccb350cee8a34dd88172..c310c7c1cef7f21538d248926aab6303cecf68b0 100644 (file)
@@ -297,7 +297,7 @@ static int netpoll_owner_active(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())
                        return 1;
        }