Re: [net PATCH] bpf: devmap fix arithmetic overflow in bitmap_size calculation

2017-10-21 Thread David Miller
From: John Fastabend Date: Thu, 19 Oct 2017 09:03:52 -0700 > An integer overflow is possible in dev_map_bitmap_size() when > calculating the BITS_TO_LONG logic which becomes, after macro > replacement, > > (((n) + (d) - 1)/ (d)) > > where 'n' is a __u32 and 'd' is (8 * sizeof(long)). To a

Re: [net PATCH] bpf: devmap fix arithmetic overflow in bitmap_size calculation

2017-10-19 Thread Alexei Starovoitov
On Thu, Oct 19, 2017 at 09:03:52AM -0700, John Fastabend wrote: > An integer overflow is possible in dev_map_bitmap_size() when > calculating the BITS_TO_LONG logic which becomes, after macro > replacement, > > (((n) + (d) - 1)/ (d)) > > where 'n' is a __u32 and 'd' is (8 * sizeof(long)). T

[net PATCH] bpf: devmap fix arithmetic overflow in bitmap_size calculation

2017-10-19 Thread John Fastabend
An integer overflow is possible in dev_map_bitmap_size() when calculating the BITS_TO_LONG logic which becomes, after macro replacement, (((n) + (d) - 1)/ (d)) where 'n' is a __u32 and 'd' is (8 * sizeof(long)). To avoid overflow cast to u64 before arithmetic. Reported-by: Richard Weinbe