Thread (4 messages) 4 messages, 3 authors, 2019-10-31

Re: [PATCH bpf] bpf: change size to u64 for bpf_map_{area_alloc,charge_init}()

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2019-10-31 20:59:57
Also in: bpf

On Tue, Oct 29, 2019 at 04:43:07PM +0100, Björn Töpel wrote:
From: Björn Töpel <redacted>

The functions bpf_map_area_alloc() and bpf_map_charge_init() prior
this commit passed the size parameter as size_t. In this commit this
is changed to u64.

All users of these functions avoid size_t overflows on 32-bit systems,
by explicitly using u64 when calculating the allocation size and
memory charge cost. However, since the result was narrowed by the
size_t when passing size and cost to the functions, the overflow
handling was in vain.

Instead of changing all call sites to size_t and handle overflow at
the call site, the parameter is changed to u64 and checked in the
functions above.

Fixes: d407bd25a204 ("bpf: don't trigger OOM killer under pressure with map alloc")
Fixes: c85d69135a91 ("bpf: move memory size checks to bpf_map_charge_init()")
Signed-off-by: Björn Töpel <redacted>
Applied, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help