Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-27 Thread Daniel Borkmann
On 1/27/21 5:23 AM, Bui Quang Minh wrote: On Tue, Jan 26, 2021 at 09:36:57AM +, Lorenz Bauer wrote: On Tue, 26 Jan 2021 at 08:26, Bui Quang Minh wrote: In 32-bit architecture, the result of sizeof() is a 32-bit integer so the expression becomes the multiplication between 2 32-bit integer

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
On Wed, Jan 27, 2021 at 11:23:41AM +0700, Bui Quang Minh wrote: > > * Seems like there are quite a few similar calls scattered around > > (cpumap, etc.). Did you audit these as well? > > I spotted another bug after re-auditting. In hashtab, there ares 2 places > using > the same calls > >

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
On Tue, Jan 26, 2021 at 09:36:57AM +, Lorenz Bauer wrote: > On Tue, 26 Jan 2021 at 08:26, Bui Quang Minh wrote: > > > > In 32-bit architecture, the result of sizeof() is a 32-bit integer so > > the expression becomes the multiplication between 2 32-bit integer which > > can potentially leads

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Lorenz Bauer
On Tue, 26 Jan 2021 at 08:26, Bui Quang Minh wrote: > > In 32-bit architecture, the result of sizeof() is a 32-bit integer so > the expression becomes the multiplication between 2 32-bit integer which > can potentially leads to integer overflow. As a result, > bpf_map_area_alloc() allocates less

[PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
In 32-bit architecture, the result of sizeof() is a 32-bit integer so the expression becomes the multiplication between 2 32-bit integer which can potentially leads to integer overflow. As a result, bpf_map_area_alloc() allocates less memory than needed. Fix this by casting 1 operand to u64.