Skip to content

Commit b524586

Browse files
committed
net: protect rxq->mp_params with the instance lock
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 <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 310ae9e commit b524586

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

net/core/dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10358,7 +10358,7 @@ u32 dev_get_min_mp_channel_count(const struct net_device *dev)
1035810358
{
1035910359
int i;
1036010360

10361-
ASSERT_RTNL();
10361+
netdev_ops_assert_locked(dev);
1036210362

1036310363
for (i = dev->real_num_rx_queues - 1; i >= 0; i--)
1036410364
if (dev->_rx[i].mp_params.mp_priv)
@@ -11962,9 +11962,9 @@ void unregister_netdevice_many_notify(struct list_head *head,
1196211962
dev_tcx_uninstall(dev);
1196311963
netdev_lock_ops(dev);
1196411964
dev_xdp_uninstall(dev);
11965+
dev_memory_provider_uninstall(dev);
1196511966
netdev_unlock_ops(dev);
1196611967
bpf_dev_bound_netdev_unregister(dev);
11967-
dev_memory_provider_uninstall(dev);
1196811968

1196911969
netdev_offload_xstats_disable_all(dev);
1197011970

net/core/page_pool.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/slab.h>
1212
#include <linux/device.h>
1313

14+
#include <net/netdev_lock.h>
1415
#include <net/netdev_rx_queue.h>
1516
#include <net/page_pool/helpers.h>
1617
#include <net/page_pool/memory_provider.h>
@@ -279,11 +280,7 @@ static int page_pool_init(struct page_pool *pool,
279280
get_device(pool->p.dev);
280281

281282
if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
282-
/* We rely on rtnl_lock()ing to make sure netdev_rx_queue
283-
* configuration doesn't change while we're initializing
284-
* the page_pool.
285-
*/
286-
ASSERT_RTNL();
283+
netdev_assert_locked(pool->slow.netdev);
287284
rxq = __netif_get_rx_queue(pool->slow.netdev,
288285
pool->slow.queue_idx);
289286
pool->mp_priv = rxq->mp_params.mp_priv;

0 commit comments

Comments
 (0)