From: sashiko-bot@kernel.org
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH mm-hotfixes v4 3/4] mm/ptdump: always stabilise against page table freeing using init_mm
Date: Thu, 16 Jul 2026 21:43:17 +0000 [thread overview]
Message-ID: <20260716214317.9891F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716-series-vmap-race-fix-v4-3-8c108c4317df@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] ptdump_walk_pgd() accesses user page tables under mmap_write_lock without draining per-VMA lock holders, allowing concurrent page table freeing to cause a use-after-free.
--
--- Patch [3]: [PATCH mm-hotfixes v4 3/4] mm/ptdump: always stabilise against page table freeing using init_mm ---
commit 75b68a063760f9b11fe2b9d0fa97f5e54d15f043
Author: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Subject: mm/ptdump: always stabilise against page table freeing using init_mm
This commit fixes races between ptdump and kernel page table freeing by
acquiring a nested mmap write lock for init_mm in ptdump_walk_pgd().
It also adds corresponding assertions to walk_page_range_debug().
> diff --git a/mm/ptdump.c b/mm/ptdump.c
> index 973020000096c..5851096e6f656 100644
> --- a/mm/ptdump.c
> +++ b/mm/ptdump.c
> @@ -178,11 +178,18 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd)
>
> get_online_mems();
> mmap_write_lock(mm);
> + /* To stabilise kernel page tables we must hold the init_mm lock too. */
> + if (mm != &init_mm)
> + mmap_write_lock_nested(&init_mm, SINGLE_DEPTH_NESTING);
> +
[Severity: High]
This isn't a bug introduced by this patch, but does this code leave us
vulnerable to a race with per-VMA lock holders?
The mmap_write_lock() alone doesn't exclude threads already holding a
per-VMA lock. Only vma_start_write() drains them. If a concurrent thread
runs a VMA-locked operation like MADV_DONTNEED, it can clear PMDs and free
PTE pages via PT_RECLAIM while this walk is happening.
Because walk_page_range_debug() configures the walk with no_vma = true,
it bypasses VMA lookup entirely:
mm/pagewalk.c:walk_page_range_debug() {
struct mm_walk walk = {
.ops = ops,
.mm = mm,
.pgd = pgd,
.private = private,
.no_vma = true
};
This means we never get a synchronization point to exclude per-VMA
operations. Could this lead to a use-after-free while walking arbitrary
user page tables?
> while (range->start != range->end) {
> walk_page_range_debug(mm, range->start, range->end,
> &ptdump_ops, pgd, st);
> range++;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716-series-vmap-race-fix-v4-0-8c108c4317df@kernel.org?part=3
next prev parent reply other threads:[~2026-07-16 21:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 21:31 [PATCH mm-hotfixes v4 0/4] mm: fix UAF caused by race between ptdump and vmap pgtable freeing Lorenzo Stoakes (ARM)
2026-07-16 21:31 ` [PATCH mm-hotfixes v4 1/4] mm/vmalloc: acquire init_mm lock on huge vmap to avoid ptdump UAF Lorenzo Stoakes (ARM)
2026-07-16 21:31 ` [PATCH mm-hotfixes v4 2/4] x86/mm/pat: acquire init_mm write lock to avoid UAF Lorenzo Stoakes (ARM)
2026-07-16 21:53 ` sashiko-bot
2026-07-17 3:46 ` David CARLIER
2026-07-17 7:47 ` Lorenzo Stoakes (ARM)
2026-07-17 8:05 ` David CARLIER
2026-07-16 21:31 ` [PATCH mm-hotfixes v4 3/4] mm/ptdump: always stabilise against page table freeing using init_mm Lorenzo Stoakes (ARM)
2026-07-16 21:43 ` sashiko-bot [this message]
2026-07-16 21:31 ` [PATCH mm-hotfixes v4 4/4] arm64: remove redundant concurrent ptdump UAF mitigation Lorenzo Stoakes (ARM)
2026-07-16 23:41 ` [PATCH mm-hotfixes v4 0/4] mm: fix UAF caused by race between ptdump and vmap pgtable freeing Andrew Morton
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=20260716214317.9891F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=ljs@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