From: sashiko-bot@kernel.org
To: "Khawar Ahemad" <ahemadkhawar123@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v6 1/4] bpf: Add a sleepable page allocator for map memory
Date: Tue, 25 Aug 2026 09:28:07 +0000 [thread overview]
Message-ID: <20260825092808.60D1B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825091647.81632-2-ahemadkhawar123@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Pages allocated with `__GFP_ZERO` for user-space mapping (BPF Arena) lack necessary dcache flushes on cache-aliasing architectures, potentially leaking uninitialized kernel memory to user space.
--
--- Patch [1]: [PATCH v6 1/4] bpf: Add a sleepable page allocator for map memory ---
commit 50003cab10c1c00ca87711f66767e18f684829b8
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
bpf: Add a sleepable page allocator for map memory
This patch adds bpf_map_alloc_page_sleepable() for callers in sleepable
contexts, such as the arena page fault handler. It avoids the non-blocking
allocator and allocates a page directly from the map's NUMA node.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 6874ba1424af0..f9b81638e537a 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
[ ... ]
> +/*
> + * For callers that know they run in a sleepable context, e.g. a user page
> + * fault handler. can_alloc_pages() is a conservative guess made for BPF
> + * program context - notably it is always false on PREEMPT_RT - so going
> + * through bpf_map_alloc_pages() there would needlessly pick the
> + * non-blocking allocator, which never reclaims and never engages the OOM
> + * machinery.
> + */
> +struct page *bpf_map_alloc_page_sleepable(const struct bpf_map *map)
> +{
> + might_sleep();
> + return alloc_pages_node(map->numa_node, BPF_PAGE_GFP, 0);
[Severity: High]
This isn't a bug introduced by this patch, but does the use of __GFP_ZERO
safely zero user-mapped pages on cache-aliasing architectures?
The __GFP_ZERO flag zeroes memory using clear_page() via the kernel's
direct mapping, which skips the dcache flush provided by functions like
clear_user_highpage().
On cache-aliasing architectures, this can cause user space to read stale data
directly from physical memory if the zeroes remain in the dcache when the
page is mapped to a different user space virtual address.
Since this function is intended for the BPF arena page fault handler to map
memory to user space, should it instead use user_alloc_needs_zeroing() and
clear_user_highpage() or folio_zero_user() rather than relying on the
__GFP_ZERO bit in BPF_PAGE_GFP?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825091647.81632-1-ahemadkhawar123@gmail.com?part=1
next prev parent reply other threads:[~2026-08-25 9:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:16 [PATCH bpf-next v6 0/4] bpf: arena: handle memory.max on fault-in with reclaim/OOM Khawar Ahemad
2026-08-25 9:16 ` [PATCH v6 1/4] bpf: Add a sleepable page allocator for map memory Khawar Ahemad
2026-08-25 9:28 ` sashiko-bot [this message]
2026-08-25 9:16 ` [PATCH v6 2/4] bpf: arena: allocate the fault-in page outside the lock Khawar Ahemad
2026-08-25 9:16 ` [PATCH v6 3/4] selftests/bpf: Add read_cgroup_file() to cgroup_helpers Khawar Ahemad
2026-08-25 9:16 ` [PATCH v6 4/4] selftests/bpf: Add a test for arena fault-in under memory.max Khawar Ahemad
-- strict thread matches above, loose matches on Subject: below --
2026-08-25 9:19 [PATCH bpf-next v6 0/4] bpf: arena: handle memory.max on fault-in with reclaim/OOM Khawar Ahemad
2026-08-25 9:19 ` [PATCH v6 1/4] bpf: Add a sleepable page allocator for map memory Khawar Ahemad
2026-08-25 9:32 ` sashiko-bot
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=20260825092808.60D1B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ahemadkhawar123@gmail.com \
--cc=bpf@vger.kernel.org \
--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