]> git.baikalelectronics.ru Git - kernel.git/commit
xsk: Fix number of pinned pages/umem size discrepancy
authorBjörn Töpel <bjorn.topel@intel.com>
Thu, 10 Sep 2020 07:56:09 +0000 (09:56 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 15 Sep 2020 01:35:09 +0000 (18:35 -0700)
commitb08c51e6daeb6fc94c01cc252f0a8103a269c9bf
tree2af01f18a1fe37a86d459a660b0bdfe569a19019
parentfd90dfd69e0565e12b431f684c1e8fd63bccab06
xsk: Fix number of pinned pages/umem size discrepancy

For AF_XDP sockets, there was a discrepancy between the number of of
pinned pages and the size of the umem region.

The size of the umem region is used to validate the AF_XDP descriptor
addresses. The logic that pinned the pages covered by the region only
took whole pages into consideration, creating a mismatch between the
size and pinned pages. A user could then pass AF_XDP addresses outside
the range of pinned pages, but still within the size of the region,
crashing the kernel.

This change correctly calculates the number of pages to be
pinned. Further, the size check for the aligned mode is
simplified. Now the code simply checks if the size is divisible by the
chunk size.

Fixes: 64f3c2c500f2 ("xsk: new descriptor addressing scheme")
Reported-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200910075609.7904-1-bjorn.topel@gmail.com
net/xdp/xdp_umem.c