Re: [PATCH bpf] xsk: add overflow check for u64 division, stored into u32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 25, 2020 at 10:03:59AM +0200, Björn Töpel wrote:
> From: Björn Töpel <bjorn.topel@xxxxxxxxx>
> 
> The npgs member of struct xdp_umem is an u32 entity, and stores the
> number of pages the UMEM consumes. The calculation of npgs
> 
>   npgs = size / PAGE_SIZE
> 
> can overflow.
> 
> To avoid overflow scenarios, the division is now first stored in a
> u64, and the result is verified to fit into 32b.
> 
> An alternative would be storing the npgs as a u64, however, this
> wastes memory and is an unrealisticly large packet area.
> 
> Link: https://lore.kernel.org/bpf/CACtPs=GGvV-_Yj6rbpzTVnopgi5nhMoCcTkSkYrJHGQHJWFZMQ@xxxxxxxxxxxxxx/
> Fixes: c0c77d8fb787 ("xsk: add user memory registration support sockopt")
> Reported-by: "Minh Bùi Quang" <minhquangbui99@xxxxxxxxx>
> Signed-off-by: Björn Töpel <bjorn.topel@xxxxxxxxx>

Acked-by: Jonathan Lemon <jonathan.lemon@xxxxxxxxx>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux