From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 3/7] bpf: Add sleepable arena page allocation path
Date: Fri, 25 Sep 2026 23:46:33 +0000 [thread overview]
Message-ID: <20260925234633.AC33F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925233538.5708-4-emil@etsalapatis.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] bpf: CPU lockups and memory pressure due to massive page allocations before range validation
--
commit 0ff0c13da92aa5b627b22373d01f9a6a0085c43f
Author: Emil Tsalapatis <emil@etsalapatis.com>
bpf: Add sleepable arena page allocation path
This commit modifies the BPF arena allocator to allocate physical pages
outside the spinlock. This allows sleepable BPF programs to use the
blocking allocator slow path when under memory pressure.
> diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
> --- a/kernel/bpf/arena.c
> +++ b/kernel/bpf/arena.c
[ ... ]
> @@ -747,8 +769,12 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt
> /* requested address will be outside of user VMA */
> return 0;
> }
> -
> bpf_map_memcg_enter(&arena->map, &old_memcg, &new_memcg);
> +
> + ret = bpf_alloc_pages(node_id, page_cnt, &pages, sleepable);
> + if (ret)
> + goto out_memcg;
> +
[Severity: High]
Could this early allocation trigger system instability or CPU lockups under
pressure?
By moving bpf_alloc_pages() before the arena_adjust_tree() check, a BPF
program can request a huge page_cnt (up to the entire arena size). Because
the physical pages are allocated before we verify if the requested virtual
address range is actually available in the range tree, this could result in
massive physical memory allocations and blocking reclaims.
If the requested virtual range is already occupied, the allocation will just
immediately free everything when the range check fails under the lock. Could
this be used by a BPF program to induce excessive memory pressure?
> data.arena = arena;
> data.pages = &pages;
> data.i = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260925233538.5708-1-emil@etsalapatis.com?part=3
next prev parent reply other threads:[~2026-09-25 23:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 23:35 [PATCH bpf v4 0/7] Make sleepable arena paths use sleepable alloc_pages Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 1/7] bpf: Use an llist for page allocations Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 2/7] bpf: Add sleepable argument to bpf_alloc_pages() Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 3/7] bpf: Add sleepable arena page allocation path Emil Tsalapatis
2026-09-25 23:46 ` sashiko-bot [this message]
2026-09-26 4:17 ` Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 4/7] selftests/bpf: Test large allocations for both sleepable/nonsleepable arena users Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 5/7] bpf: Support call-site kfunc specialization for near calls Emil Tsalapatis
2026-09-25 23:35 ` [PATCH bpf-next v4 6/7] bpf: Support call-site kfunc specialization for far calls Emil Tsalapatis
2026-09-26 8:26 ` Alexei Starovoitov
2026-09-25 23:35 ` [PATCH bpf-next v4 7/7] selftests/bpf: Test per-call site function specialization Emil Tsalapatis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925234633.AC33F1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=emil@etsalapatis.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox