summaryrefslogtreecommitdiffstats
path: root/net/xdp
diff options
context:
space:
mode:
authorKal Conley <kal.conley@dectris.com>2023-04-06 01:59:18 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-17 11:47:50 +0200
commit5877980dc2e47119a14cf084159672317d4dd6b7 (patch)
tree484bb8c0ed31475b733dfab7c005db60005d742f /net/xdp
parent2a67bc52cd3f0783ac412d8007ae7bdd04911b10 (diff)
downloadlinux-stable-5877980dc2e47119a14cf084159672317d4dd6b7.tar.gz
linux-stable-5877980dc2e47119a14cf084159672317d4dd6b7.tar.bz2
linux-stable-5877980dc2e47119a14cf084159672317d4dd6b7.zip
xsk: Fix unaligned descriptor validation
[ Upstream commit d769ccaf957fe7391f357c0a923de71f594b8a2b ] Make sure unaligned descriptors that straddle the end of the UMEM are considered invalid. Currently, descriptor validation is broken for zero-copy mode which only checks descriptors at page granularity. For example, descriptors in zero-copy mode that overrun the end of the UMEM but not a page boundary are (incorrectly) considered valid. The UMEM boundary check needs to happen before the page boundary and contiguity checks in xp_desc_crosses_non_contig_pg(). Do this check in xp_unaligned_validate_desc() instead like xp_check_unaligned() already does. Fixes: 2b43470add8c ("xsk: Introduce AF_XDP buffer allocation API") Signed-off-by: Kal Conley <kal.conley@dectris.com> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/r/20230405235920.7305-2-kal.conley@dectris.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/xdp')
-rw-r--r--net/xdp/xsk_queue.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index 3c7ce60fe9a5..a76d43787549 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -155,6 +155,7 @@ static inline bool xp_unaligned_validate_desc(struct xsk_buff_pool *pool,
return false;
if (base_addr >= pool->addrs_cnt || addr >= pool->addrs_cnt ||
+ addr + desc->len > pool->addrs_cnt ||
xp_desc_crosses_non_contig_pg(pool, addr, desc->len))
return false;