mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
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 inbbff2f321a
("xsk: new descriptor addressing scheme"). Later in2b43470add
("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 via26062b185e
("xsk: Explicitly inline functions and move definitions"). Fixes:bbff2f321a
("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
This commit is contained in:
parent
2a30f94406
commit
ac31565c21
@ -128,13 +128,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
|
||||
static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
|
||||
struct xdp_desc *desc)
|
||||
{
|
||||
u64 chunk, chunk_end;
|
||||
u64 chunk;
|
||||
|
||||
chunk = xp_aligned_extract_addr(pool, desc->addr);
|
||||
chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len);
|
||||
if (chunk != chunk_end)
|
||||
if (desc->len > pool->chunk_size)
|
||||
return false;
|
||||
|
||||
chunk = xp_aligned_extract_addr(pool, desc->addr);
|
||||
if (chunk >= pool->addrs_cnt)
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user