BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Muhammad Usama Anjum" <usama.anjum@arm.com>
Cc: bpf@vger.kernel.org, linux-perf-users@vger.kernel.org,
	damon@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/9] mm/kasan: use hw_pte_t for the early shadow PTE table
Date: Thu, 06 Aug 2026 09:01:21 +0000	[thread overview]
Message-ID: <20260806090121.C013F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806083926.1807279-8-usama.anjum@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Invalid non-present page table entry conversion in ptdump callbacks.
--

--- Patch [7]: [PATCH 7/9] mm/kasan: use hw_pte_t for the early shadow PTE table ---
commit 3ee38376d3d7f9e85666863e4080641fcf9b048b
Author: Muhammad Usama Anjum <usama.anjum@arm.com>

mm/kasan: use hw_pte_t for the early shadow PTE table

kasan_early_shadow_pte is a complete PTE table rather than a standalone
PTE value. Declare and define its elements as hw_pte_t so the object uses
the PTE table storage type.

[ ... ]

> diff --git a/mm/ptdump.c b/mm/ptdump.c
> index 376880071ca2a..8f19f20be3c44 100644
> --- a/mm/ptdump.c
> +++ b/mm/ptdump.c
> @@ -19,7 +19,7 @@ static inline int note_kasan_page_table(struct mm_walk *walk,
>  {
>  	struct ptdump_state *st = walk->private;
>  
> -	st->note_page_pte(st, addr, kasan_early_shadow_pte[0]);
> +	st->note_page_pte(st, addr, ptep_get(kasan_early_shadow_pte));

[Severity: High]
This isn't a bug introduced by this patch, but since we are modifying the KASAN
shadow table handling in ptdump, are the page extraction checks that lead here
safe for non-present entries?

In mm/ptdump.c, callbacks like ptdump_pmd_entry() and ptdump_pud_entry()
unconditionally call pmd_page() and pud_page() before checking if the entry
is present:

mm/ptdump.c:ptdump_pmd_entry() {
    ...
	pmd_t val = pmdp_get(pmd);

#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
	if (pmd_page(val) == virt_to_page(lm_alias(kasan_early_shadow_pte)))
		return note_kasan_page_table(walk, addr);
#endif
    ...
}

User page tables can contain non-present swap or migration entries at the PMD
level. If pmd_page() (and equivalents like pud_page(), p4d_page(), pgd_page())
extracts a bogus PFN from a non-present entry, could this lead to an
out-of-bounds array access and a NULL pointer dereference in the sparsemem
arrays when pfn_to_page() is evaluated?

Since ptdump can be invoked on user page tables via debugfs by users with read
access, could this trigger a kernel panic? Should these callbacks verify the
entry is present before calling the page conversion functions?

>  
>  	walk->action = ACTION_CONTINUE;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806083926.1807279-1-usama.anjum@arm.com?part=7

  reply	other threads:[~2026-08-06  9:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  8:38 [PATCH 0/9] mm: distinguish PTE table storage from PTE values Muhammad Usama Anjum
2026-08-06  8:38 ` [PATCH 1/9] mm: introduce hw_pte_t for PTE table storage Muhammad Usama Anjum
2026-08-07  7:09   ` Alexander Gordeev
2026-08-06  8:38 ` [PATCH 2/9] mm: make hw_pte_t visible to generic PTE interfaces Muhammad Usama Anjum
2026-08-06  8:38 ` [PATCH 3/9] mm: name pointers to copied PTE values ptentp Muhammad Usama Anjum
2026-08-06  8:38 ` [PATCH 4/9] mm: use hw_pte_t for generic PTE table storage Muhammad Usama Anjum
2026-08-06  9:00   ` sashiko-bot
2026-08-06  8:38 ` [PATCH 5/9] mm: convert PTE table entries in ptep_get() Muhammad Usama Anjum
2026-08-06  8:57   ` sashiko-bot
2026-08-06  8:38 ` [PATCH 6/9] mm: convert PTE table entry to pte Muhammad Usama Anjum
2026-08-07  6:58   ` Alexander Gordeev
2026-08-06  8:38 ` [PATCH 7/9] mm/kasan: use hw_pte_t for the early shadow PTE table Muhammad Usama Anjum
2026-08-06  9:01   ` sashiko-bot [this message]
2026-08-06  8:38 ` [PATCH 8/9] drm/i915: use hw_pte_t for PTE range callbacks Muhammad Usama Anjum
2026-08-06  8:38 ` [PATCH 9/9] xen: " Muhammad Usama Anjum

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=20260806090121.C013F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=usama.anjum@arm.com \
    /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