Re: [PATCH] bpf: use kvzmalloc to allocate BPF verifier environment

From: Shakeel Butt
Date: Tue Oct 08 2024 - 17:39:49 EST


On Tue, Oct 08, 2024 at 05:07:35PM GMT, Rik van Riel wrote:
> The kzmalloc call in bpf_check can fail when memory is very fragmented,
> which in turn can lead to an OOM kill.
>
> Use kvzmalloc to fall back to vmalloc when memory is too fragmented to
> allocate an order 3 sized bpf verifier environment.
>
> Admittedly this is not a very common case, and only happens on systems
> where memory has already been squeezed close to the limit, but this does
> not seem like much of a hot path, and it's a simple enough fix.
>
> Signed-off-by: Rik van Riel <riel@xxxxxxxxxxx>

It seems like a temporary allocation, so using kvmalloc* seems
reasonable.

Reviewed-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>