]> git.hungrycats.org Git - linux/commit
bpf: use kvzmalloc to allocate BPF verifier environment
authorRik van Riel <riel@surriel.com>
Tue, 8 Oct 2024 21:07:35 +0000 (17:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Nov 2024 13:59:39 +0000 (14:59 +0100)
commit4d8f6679b03ab39734af0cabc883cde5c9c95ff4
treeb9c1fc18fcb0d934f7cb2eca61b571d9aaf012bd
parent0bf6971b7d1e0b3fdc5e8bfa7e0f482b9beaf099
bpf: use kvzmalloc to allocate BPF verifier environment

[ Upstream commit 434247637c66e1be2bc71a9987d4c3f0d8672387 ]

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@surriel.com>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://lore.kernel.org/r/20241008170735.16766766@imladris.surriel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/verifier.c