]> git.baikalelectronics.ru Git - kernel.git/commit
xsk: Clear pool even for inactive queues
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Mon, 18 Jan 2021 16:03:33 +0000 (18:03 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 19 Jan 2021 21:47:04 +0000 (22:47 +0100)
commit4d559acb4ccb8cc33ffb0271e64a63b915e2040c
treec44bdeeda97f5b4f683e2220bc63d56061bcf1e3
parent6abdbcb3ab6ca47f5e82d66f5624e24fcaa54a34
xsk: Clear pool even for inactive queues

The number of queues can change by other means, rather than ethtool. For
example, attaching an mqprio qdisc with num_tc > 1 leads to creating
multiple sets of TX queues, which may be then destroyed when mqprio is
deleted. If an AF_XDP socket is created while mqprio is active,
dev->_tx[queue_id].pool will be filled, but then real_num_tx_queues may
decrease with deletion of mqprio, which will mean that the pool won't be
NULLed, and a further increase of the number of TX queues may expose a
dangling pointer.

To avoid any potential misbehavior, this commit clears pool for RX and
TX queues, regardless of real_num_*_queues, still taking into
consideration num_*_queues to avoid overflows.

Fixes: 8d2660363f39 ("xsk: Create and free buffer pool independently from umem")
Fixes: 3939828c7ff5 ("xsk: simplify xdp_clear_umem_at_qid implementation")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Link: https://lore.kernel.org/bpf/20210118160333.333439-1-maximmi@mellanox.com
net/xdp/xsk.c