mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 01:22:07 +00:00
xsk: add missing write- and data-dependency barrier
Here, we add a missing write-barrier, and use READ_ONCE for the data-dependency barrier. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
1c4917da36
commit
37b076933a
@ -228,6 +228,8 @@ static int xsk_init_queue(u32 entries, struct xsk_queue **queue,
|
|||||||
if (!q)
|
if (!q)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/* Make sure queue is ready before it can be seen by others */
|
||||||
|
smp_wmb();
|
||||||
*queue = q;
|
*queue = q;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -532,21 +534,23 @@ static int xsk_mmap(struct file *file, struct socket *sock,
|
|||||||
unsigned long size = vma->vm_end - vma->vm_start;
|
unsigned long size = vma->vm_end - vma->vm_start;
|
||||||
struct xdp_sock *xs = xdp_sk(sock->sk);
|
struct xdp_sock *xs = xdp_sk(sock->sk);
|
||||||
struct xsk_queue *q = NULL;
|
struct xsk_queue *q = NULL;
|
||||||
|
struct xdp_umem *umem;
|
||||||
unsigned long pfn;
|
unsigned long pfn;
|
||||||
struct page *qpg;
|
struct page *qpg;
|
||||||
|
|
||||||
if (offset == XDP_PGOFF_RX_RING) {
|
if (offset == XDP_PGOFF_RX_RING) {
|
||||||
q = xs->rx;
|
q = READ_ONCE(xs->rx);
|
||||||
} else if (offset == XDP_PGOFF_TX_RING) {
|
} else if (offset == XDP_PGOFF_TX_RING) {
|
||||||
q = xs->tx;
|
q = READ_ONCE(xs->tx);
|
||||||
} else {
|
} else {
|
||||||
if (!xs->umem)
|
umem = READ_ONCE(xs->umem);
|
||||||
|
if (!umem)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (offset == XDP_UMEM_PGOFF_FILL_RING)
|
if (offset == XDP_UMEM_PGOFF_FILL_RING)
|
||||||
q = xs->umem->fq;
|
q = READ_ONCE(umem->fq);
|
||||||
else if (offset == XDP_UMEM_PGOFF_COMPLETION_RING)
|
else if (offset == XDP_UMEM_PGOFF_COMPLETION_RING)
|
||||||
q = xs->umem->cq;
|
q = READ_ONCE(umem->cq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!q)
|
if (!q)
|
||||||
|
Loading…
Reference in New Issue
Block a user