From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 2/3] bpf: Add sleepable arena page allocation path
Date: Mon, 24 Aug 2026 08:43:38 +0000 [thread overview]
Message-ID: <20260824084339.501411F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260824082530.47553-3-emil@etsalapatis.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Hard lockup via integer overflow: `data.i << PAGE_SHIFT` passes an astronomically large negative size to `flush_vmap_cache` on mapping failure.
--
--- Patch [2]: [PATCH 2/3] bpf: Add sleepable arena page allocation path ---
commit a93c0f542ad1ecf8f00cde8cf86699ce952035a7
Author: Emil Tsalapatis <emil@etsalapatis.com>
bpf: Add sleepable arena page allocation path
This commit adds a separate sleepable allocation path for BPF arena memory.
It preallocates memory before taking the critical section to prevent
frequent allocation failures from sleepable BPF contexts.
> diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
> index da356989786a0..126ddae763f9a 100644
> --- a/kernel/bpf/arena.c
> +++ b/kernel/bpf/arena.c
[ ... ]
> +static long arena_alloc_pages_sleepable(struct bpf_arena *arena, long page_cnt,
> + long uaddr, long pgoff, int node_id)
> +{
[ ... ]
> +out_unmap:
> + /* data.i pages were mapped, undo only those who failed to map */
> + flush_vmap_cache(kern_vm_start + uaddr32, data.i << PAGE_SHIFT);
[Severity: High]
Can this shift operation overflow?
If apply_to_page_range() maps a large number of pages (e.g. over 524,287)
before failing, data.i << PAGE_SHIFT will overflow since data.i is a
signed 32-bit int.
Because flush_vmap_cache() expects an unsigned long size, a negative value
here would sign-extend to a massive 64-bit size, potentially causing a CPU
stall or lockup in the flush routine.
Would casting data.i to unsigned long before the shift prevent this?
> + range_tree_set(&arena->rt, pgoff + data.i, page_cnt - data.i);
> +
> + raw_res_spin_unlock_irqrestore(&arena->spinlock, flags);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824082530.47553-1-emil@etsalapatis.com?part=2
next prev parent reply other threads:[~2026-08-24 8:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 8:25 [PATCH 0/3] bpf: Make sleepable arena paths use sleepable alloc_pages Emil Tsalapatis
2026-08-24 8:25 ` [PATCH 1/3] bpf: Factor out nonsleepable arena allocation logic Emil Tsalapatis
2026-08-24 9:24 ` bot+bpf-ci
2026-08-24 8:25 ` [PATCH 2/3] bpf: Add sleepable arena page allocation path Emil Tsalapatis
2026-08-24 8:43 ` sashiko-bot [this message]
2026-08-24 9:42 ` bot+bpf-ci
2026-08-26 1:25 ` Alexei Starovoitov
2026-09-23 21:48 ` Emil Tsalapatis
2026-09-23 23:24 ` Alexei Starovoitov
2026-08-24 8:25 ` [PATCH 3/3] selftests/bpf: Test large allocations for both sleepable/nonsleepable arena users Emil Tsalapatis
2026-08-24 8:39 ` sashiko-bot
2026-08-24 9:24 ` bot+bpf-ci
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=20260824084339.501411F00A3D@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.