From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 4/4] mm/mempolicy: skip zone device folios when queueing folios
Date: Tue, 28 Jul 2026 19:59:34 +0000 [thread overview]
Message-ID: <20260728195934.A61511F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728194714.3713735-5-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] queue_folios_pmd() blindly calls pmd_folio() on raw PFN PMDs, causing a kernel panic during mbind(MPOL_MF_STRICT) on VM_PFNMAP mappings.
--
--- Patch [4]: [PATCH 4/4] mm/mempolicy: skip zone device folios when queueing folios ---
commit 638b94b8502c12252205f411cec0cf58a9fd9ce2
Author: Gregory Price <gourry@gourry.net>
mm/mempolicy: skip zone device folios when queueing folios
This commit adds explicit zone device checks to queue_folios_pmd() and
queue_folios_hugetlb() to mirror the behavior in queue_folios_pte_range().
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 5720f7f54d942..bd79e61a40d1a 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -668,6 +668,8 @@ static void queue_folios_pmd(pmd_t *pmd, struct mm_walk *walk)
> }
> if (!queue_folio_required(folio, qp))
> return;
> + if (folio_is_zone_device(folio))
> + return;
[Severity: High]
This is a pre-existing issue, but can this code path trigger a kernel panic
if it encounters a raw PFN PMD from a VM_PFNMAP mapping?
Looking at queue_pages_test_walk() in mm/mempolicy.c, it allows unmigratable
VMAs (like VM_PFNMAP) to be walked if MPOL_MF_STRICT is specified:
if (!vma_migratable(vma) &&
!(flags & MPOL_MF_STRICT))
return 1;
if (flags & (MPOL_MF_STRICT | MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
return 0;
During the walk, queue_folios_pmd() unconditionally calls pmd_folio(pmdval)
on present PMDs. Since VM_PFNMAP raw PFNs lack a valid struct page,
pmd_folio() would return a garbage pointer, leading to a crash when
queue_folio_required() or the newly added folio_is_zone_device() dereferences
it.
Should queue_folios_pmd() be using vm_normal_folio_pmd() or similar to filter
out raw PFN mappings before attempting to extract the folio?
> if (!(qp->flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) ||
> !vma_migratable(walk->vma) ||
> !migrate_folio_add(folio, qp->pagelist, qp->flags))
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728194714.3713735-1-gourry@gourry.net?part=4
prev parent reply other threads:[~2026-07-28 19:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 19:47 [PATCH 0/4] mm: reject zone device folios in more folio walkers Gregory Price
2026-07-28 19:47 ` [PATCH 1/4] mm/damon: defensively skip zone device folios in damon_get_folio() Gregory Price
2026-07-28 19:57 ` sashiko-bot
2026-07-28 20:16 ` Gregory Price
2026-07-29 0:55 ` SJ Park
2026-07-29 0:50 ` SJ Park
2026-07-29 2:01 ` Gregory Price
2026-07-28 19:47 ` [PATCH 2/4] mm/huge_memory: skip zone device folios in madvise_free_huge_pmd() Gregory Price
2026-07-28 20:01 ` sashiko-bot
2026-07-28 19:47 ` [PATCH 3/4] mm/madvise: skip zone device folios in cold/pageout PMD range Gregory Price
2026-07-28 19:58 ` sashiko-bot
2026-07-28 19:47 ` [PATCH 4/4] mm/mempolicy: skip zone device folios when queueing folios Gregory Price
2026-07-28 19:59 ` sashiko-bot [this message]
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=20260728195934.A61511F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=gourry@gourry.net \
--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.