From: sashiko-bot@kernel.org
To: "Kevin Brodsky" <kevin.brodsky@arm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH 17/22] mm: pagewalk: drop redundant address check for kernel mm walks
Date: Tue, 14 Jul 2026 14:42:31 +0000 [thread overview]
Message-ID: <20260714144232.641C81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-remove_pgtable_cdtor-v1-17-44be8a7685d7@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Removing the `addr >= TASK_SIZE` check in `walk_pte_range()` causes `ptdump` to clear valid kernel PMDs, leading to memory corruption and a kernel panic.
--
--- Patch [17]: [PATCH 17/22] mm: pagewalk: drop redundant address check for kernel mm walks ---
commit 85b512e55cb35ec57a18d00b67fbf62a68320627
Author: Kevin Brodsky <kevin.brodsky@arm.com>
mm: pagewalk: drop redundant address check for kernel mm walks
This commit removes the addr >= TASK_SIZE check from walk_pte_range() for
no-VMA walks. It relies entirely on mm_is_kernel() to determine whether
to use pte_offset_kernel() or pte_offset_map().
> diff --git a/mm/pagewalk.c b/mm/pagewalk.c
> index a3f47d1de3c5a..0dd9d4ad9b689 100644
> --- a/mm/pagewalk.c
> +++ b/mm/pagewalk.c
> @@ -68,17 +68,14 @@ static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
> if (walk->no_vma) {
> /*
> * pte_offset_map() might apply user-specific validation.
> - * Indeed, on x86_64 the pmd entries set up by init_espfix_ap()
> - * fit its pmd_bad() check (_PAGE_NX set and _PAGE_RW clear),
> - * and CONFIG_EFI_PGT_DUMP efi_mm goes so far as to walk them.
> */
> - if (mm_is_kernel(walk->mm) || addr >= TASK_SIZE)
> + if (mm_is_kernel(walk->mm))
> pte = pte_offset_kernel(pmd, addr);
> else
> pte = pte_offset_map(pmd, addr);
[Severity: High]
Does removing the addr >= TASK_SIZE check here cause ptdump to clear valid
kernel PMDs?
When tools like ptdump walk the address space (e.g. via
/sys/kernel/debug/page_tables/current_kernel), they may walk kernel addresses
using current->mm, which is a user mm. In this case, mm_is_kernel() returns
false, causing walk_pte_range() to use pte_offset_map() for kernel addresses.
On x86, pte_offset_map() eventually calls __pte_offset_map(), which validates
the PMD using pmd_bad(). If a kernel PMD (such as the espfix mapping) fails
this check because it intentionally lacks _PAGE_RW and sets _PAGE_NX,
__pte_offset_map() unconditionally clears it via pmd_clear_bad().
Since kernel page tables are shared via init_mm, clearing the PMD permanently
destroys the global espfix mapping. The next IRET to a 16-bit userspace
segment would then encounter a missing page table, triggering a Double Fault
kernel panic.
Should we keep the addr >= TASK_SIZE check to ensure kernel addresses always
use pte_offset_kernel(), even when walked via a user mm?
> if (pte) {
> err = walk_pte_range_inner(pte, addr, end, walk);
> - if (!mm_is_kernel(walk->mm) && addr < TASK_SIZE)
> + if (!mm_is_kernel(walk->mm))
> pte_unmap(pte);
> }
> } else {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com?part=17
next prev parent reply other threads:[~2026-07-14 14:42 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 14:03 [PATCH 00/22] Simplify special kernel page table handling Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 01/22] mm: drop unused __mm_flags_set_mask_bits_word() Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 02/22] mm: move mm_flags helpers to mm_types.h Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 03/22] mm: introduce MMF_KERNEL flag and set it for init_mm Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:47 ` Dave Hansen
2026-07-14 14:47 ` Dave Hansen
2026-07-14 15:04 ` Lorenzo Stoakes (ARM)
2026-07-14 15:04 ` Lorenzo Stoakes (ARM)
2026-07-14 14:03 ` [PATCH 04/22] mm: use mm_is_kernel() in generic page table code Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:28 ` sashiko-bot
2026-07-14 14:03 ` [PATCH 05/22] arm64: mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 06/22] loongarch: mm: use mm_is_kernel() in switch_mm_irqs_off() Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 07/22] parisc: mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 08/22] powerpc: " Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 09/22] s390: " Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:03 ` [PATCH 10/22] sparc: " Kevin Brodsky
2026-07-14 14:03 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 11/22] um: mm: use mm_is_kernel() in TLB sync Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 12/22] x86/mm: use mm_is_kernel() for kernel mm checks Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 15:09 ` Dave Hansen
2026-07-14 15:09 ` Dave Hansen
2026-07-14 14:04 ` [PATCH 13/22] mm: account page table pages when allocated Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:54 ` sashiko-bot
2026-07-14 14:04 ` [PATCH 14/22] mm: set page table page type " Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:54 ` sashiko-bot
2026-07-14 15:16 ` Vishal Moola
2026-07-14 15:16 ` Vishal Moola
2026-07-14 14:04 ` [PATCH 15/22] mm: only initialise pt_share_count for user pgtables Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 16/22] efi: mark efi_mm as a kernel mm Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 15:16 ` sashiko-bot
2026-07-14 14:04 ` [PATCH 17/22] mm: pagewalk: drop redundant address check for kernel mm walks Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:42 ` sashiko-bot [this message]
2026-07-14 14:04 ` [PATCH 18/22] arm64: mm: drop explicit mm_is_efi() check in contpte Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 19/22] x86/tboot: mark tboot_mm as a kernel mm Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 15:19 ` Dave Hansen
2026-07-14 15:19 ` Dave Hansen
2026-07-14 14:04 ` [PATCH 20/22] arm64: mm: drop ctor/dtor calls for kernel page tables Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:56 ` sashiko-bot
2026-07-14 14:04 ` [PATCH 21/22] arm: mm: drop ctor call " Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
2026-07-14 14:04 ` [PATCH 22/22] riscv: mm: drop ctor/dtor calls " Kevin Brodsky
2026-07-14 14:04 ` Kevin Brodsky
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=20260714144232.641C81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-s390@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 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.