From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 1/4] bpf: Add call for selecting kmalloc or kmalloc_nolock at call time
Date: Tue, 24 Nov 2026 06:21:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-230586@kernel.org> (raw)
In-Reply-To: <20261124060357.11700-2-emil@etsalapatis.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] bpf: missing dcache flush in __bpf_alloc_page() [1]
--
commit 761d9aaa5b4ddd842253567eefeb0a2ef78a0aa0
Author: Emil Tsalapatis <emil@etsalapatis.com>
bpf: Add call for selecting kmalloc or kmalloc_nolock at call time
This commit adds bpf_map_kmalloc_maylock() to attempt a non-sleeping
kmalloc() when spinning is safe before falling back to kmalloc_nolock(),
and switches BPF local storage allocations to use it.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index ec8e787929112..4c72b05e11eb0 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
[ ... ]
> @@ -627,5 +627,5 @@ void *bpf_map_kmalloc_maylock(const struct bpf_map *map, size_t size, gfp_t flag
> struct page *bpf_alloc_page(int nid, bool sleepable)
> {
> - if (!sleepable || !can_alloc_pages())
> + if (!sleepable || !can_spin_in_alloc())
> return alloc_pages_nolock(__GFP_ACCOUNT, nid, 0);
>
[Severity: Critical]
This problem wasn't introduced by this patch, but does bpf_alloc_page()
miss a dcache flush on cache-aliasing architectures [1]?
Both alloc_pages_nolock() and alloc_pages_node(..., __GFP_ZERO, ...) zero
the page through the kernel linear mapping, leaving the zeroed lines in
the CPU data cache without flushing them to main memory. When user space
subsequently mmaps the BPF map or arena page at an aliasing virtual
address, the CPU can bypass those dirty cache lines and read stale data
from physical memory, disclosing uninitialized kernel memory to user
space.
[1] https://sashiko.dev/#/bug/linux-f9f23bef-4238-4cdc-90e6-85c0f416ca5b
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124060357.11700-1-emil@etsalapatis.com?part=1
next prev parent reply other threads:[~2026-11-24 6:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 6:03 [PATCH bpf-next v1 0/4] bpf: Use kmalloc for local storage if possible Emil Tsalapatis
2026-11-24 6:03 ` [PATCH bpf-next v1 1/4] bpf: Add call for selecting kmalloc or kmalloc_nolock at call time Emil Tsalapatis
2026-11-24 6:21 ` sashiko-bot [this message]
2026-11-24 6:40 ` Alexei Starovoitov
2026-11-24 6:40 ` bot+bpf-ci
2026-11-24 6:03 ` [PATCH bpf-next v1 2/4] bpf: Plumb local storage context Emil Tsalapatis
2026-11-24 6:17 ` sashiko-bot
2026-11-24 6:03 ` [PATCH bpf-next v1 3/4] bpf: Add sleepable local storage Emil Tsalapatis
2026-11-24 6:40 ` bot+bpf-ci
2026-11-24 6:41 ` sashiko-bot
2026-11-24 6:03 ` [PATCH bpf-next v1 4/4] selftests/bpf: Test kmalloc variant selection for task storage Emil Tsalapatis
2026-11-24 6:40 ` 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=sashiko-outbox-230586@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