Skip to content

Commit ac31565

Browse files
fengidriborkmann
authored andcommitted
xsk: Fix for xp_aligned_validate_desc() when len == chunk_size
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 2a30f94 commit ac31565

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

net/xdp/xsk_queue.h

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

133-
chunk = xp_aligned_extract_addr(pool, desc->addr);
134-
chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len);
135-
if (chunk != chunk_end)
133+
if (desc->len > pool->chunk_size)
136134
return false;
137135

136+
chunk = xp_aligned_extract_addr(pool, desc->addr);
138137
if (chunk >= pool->addrs_cnt)
139138
return false;
140139

0 commit comments

Comments
 (0)