Skip to content

Commit 7fcf26b

Browse files
magnus-karlssonborkmann
authored andcommitted
Revert "xsk: Support redirect to any socket bound to the same umem"
This reverts commit 2863d66. This patch introduced a potential kernel crash when multiple napi instances redirect to the same AF_XDP socket. By removing the queue_index check, it is possible for multiple napi instances to access the Rx ring at the same time, which will result in a corrupted ring state which can lead to a crash when flushing the rings in __xsk_flush(). This can happen when the linked list of sockets to flush gets corrupted by concurrent accesses. A quick and small fix is not possible, so let us revert this for now. Reported-by: Yuval El-Hanany <[email protected]> Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/xdp-newbies/[email protected] Link: https://lore.kernel.org/bpf/[email protected]
1 parent d0d1df8 commit 7fcf26b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

net/xdp/xsk.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,10 @@ static bool xsk_is_bound(struct xdp_sock *xs)
313313

314314
static int xsk_rcv_check(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
315315
{
316-
struct net_device *dev = xdp->rxq->dev;
317-
u32 qid = xdp->rxq->queue_index;
318-
319316
if (!xsk_is_bound(xs))
320317
return -ENXIO;
321318

322-
if (!dev->_rx[qid].pool || xs->umem != dev->_rx[qid].pool->umem)
319+
if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index)
323320
return -EINVAL;
324321

325322
if (len > xsk_pool_get_rx_frame_size(xs->pool) && !xs->sg) {

0 commit comments

Comments
 (0)