Skip to content

Commit 340de91

Browse files
fengidrigregkh
authored andcommitted
xsk: Fix for xp_aligned_validate_desc() when len == chunk_size
[ Upstream commit ac31565 ] When desc->len is equal to chunk_size, it is legal. But when the xp_aligned_validate_desc() got chunk_end from desc->addr + desc->len pointing to the next chunk during the check, it caused the check to fail. This problem was first introduced in bbff2f3 ("xsk: new descriptor addressing scheme"). Later in 2b43470 ("xsk: Introduce AF_XDP buffer allocation API") this piece of code was moved into the new function called xp_aligned_validate_desc(). This function was then moved into xsk_queue.h via 26062b1 ("xsk: Explicitly inline functions and move definitions"). Fixes: bbff2f3 ("xsk: new descriptor addressing scheme") Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20210428094424.54435-1-xuanzhuo@linux.alibaba.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 75ea982 commit 340de91

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎net/xdp/xsk_queue.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
126126
static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
127127
struct xdp_desc *desc)
128128
{
129-
u64 chunk, chunk_end;
129+
u64 chunk;
130130

131-
chunk = xp_aligned_extract_addr(pool, desc->addr);
132-
chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len);
133-
if (chunk != chunk_end)
131+
if (desc->len > pool->chunk_size)
134132
return false;
135133

134+
chunk = xp_aligned_extract_addr(pool, desc->addr);
136135
if (chunk >= pool->addrs_cnt)
137136
return false;
138137

0 commit comments

Comments
 (0)