Commit e6762c8bcf982821935a2b1cb33cf8335d0eefae
Committed by
Alexei Starovoitov
1 parent
b90efd2258
xsk: add missing smp_rmb() in xsk_mmap
All the setup code in AF_XDP is protected by a mutex with the exception of the mmap code that cannot use it. To make sure that a process banging on the mmap call at the same time as another process is setting up the socket, smp_wmb() calls were added in the umem registration code and the queue creation code, so that the published structures that xsk_mmap needs would be consistent. However, the corresponding smp_rmb() calls were not added to the xsk_mmap code. This patch adds these calls. Fixes: 37b076933a8e3 ("xsk: add missing write- and data-dependency barrier") Fixes: c0c77d8fb787c ("xsk: add user memory registration support sockopt") Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff
net/xdp/xsk.c
... | ... | @@ -669,6 +669,8 @@ |
669 | 669 | if (!umem) |
670 | 670 | return -EINVAL; |
671 | 671 | |
672 | + /* Matches the smp_wmb() in XDP_UMEM_REG */ | |
673 | + smp_rmb(); | |
672 | 674 | if (offset == XDP_UMEM_PGOFF_FILL_RING) |
673 | 675 | q = READ_ONCE(umem->fq); |
674 | 676 | else if (offset == XDP_UMEM_PGOFF_COMPLETION_RING) |
... | ... | @@ -678,6 +680,8 @@ |
678 | 680 | if (!q) |
679 | 681 | return -EINVAL; |
680 | 682 | |
683 | + /* Matches the smp_wmb() in xsk_init_queue */ | |
684 | + smp_rmb(); | |
681 | 685 | qpg = virt_to_head_page(q->ring); |
682 | 686 | if (size > (PAGE_SIZE << compound_order(qpg))) |
683 | 687 | return -EINVAL; |