]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: protect rxq->mp_params with the instance lock
authorJakub Kicinski <kuba@kernel.org>
Mon, 24 Mar 2025 22:45:33 +0000 (15:45 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 25 Mar 2025 17:06:49 +0000 (10:06 -0700)
Ensure that all accesses to mp_params are under the netdev
instance lock. The only change we need is to move
dev_memory_provider_uninstall() under the lock.

Appropriately swap the asserts.

Reviewed-by: Mina Almasry <almasrymina@google.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250324224537.248800-8-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c
net/core/page_pool.c

index ab74e1f005d2ec85c7e12f2de846b65e5e7b55be..b597cc27a115c39c0f4bc069919b08aa5cfef922 100644 (file)
@@ -10358,7 +10358,7 @@ u32 dev_get_min_mp_channel_count(const struct net_device *dev)
 {
        int i;
 
-       ASSERT_RTNL();
+       netdev_ops_assert_locked(dev);
 
        for (i = dev->real_num_rx_queues - 1; i >= 0; i--)
                if (dev->_rx[i].mp_params.mp_priv)
@@ -11962,9 +11962,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
                dev_tcx_uninstall(dev);
                netdev_lock_ops(dev);
                dev_xdp_uninstall(dev);
+               dev_memory_provider_uninstall(dev);
                netdev_unlock_ops(dev);
                bpf_dev_bound_netdev_unregister(dev);
-               dev_memory_provider_uninstall(dev);
 
                netdev_offload_xstats_disable_all(dev);
 
index acef1fcd8ddcfd1853a6f2055c1f1820ab248e8d..7745ad924ae2d801580a6760eba9393e1cf67b01 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/slab.h>
 #include <linux/device.h>
 
+#include <net/netdev_lock.h>
 #include <net/netdev_rx_queue.h>
 #include <net/page_pool/helpers.h>
 #include <net/page_pool/memory_provider.h>
@@ -279,11 +280,7 @@ static int page_pool_init(struct page_pool *pool,
                get_device(pool->p.dev);
 
        if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
-               /* We rely on rtnl_lock()ing to make sure netdev_rx_queue
-                * configuration doesn't change while we're initializing
-                * the page_pool.
-                */
-               ASSERT_RTNL();
+               netdev_assert_locked(pool->slow.netdev);
                rxq = __netif_get_rx_queue(pool->slow.netdev,
                                           pool->slow.queue_idx);
                pool->mp_priv = rxq->mp_params.mp_priv;