Re: [RFC 1/1] mm/pagewalk: don't split device-backed huge pfnmaps
From: David Hildenbrand (Arm)
Date: Mon Mar 09 2026 - 16:20:11 EST
On 3/9/26 18:49, Max Boone wrote:
> Don't split and descend on special PMD/PUDs, which are generally
> device-backed huge pfnmaps as used by vfio for BAR mapping. These
> can be faulted back in after splitting and before descending, which
> can race to an illegal read.
>
> Signed-off-by: Max Boone <mboone@xxxxxxxxxx>
> Signed-off-by: Max Tottenham <mtottenh@xxxxxxxxxx>
>
> ---
> mm/pagewalk.c | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/mm/pagewalk.c b/mm/pagewalk.c
> index a94c401ab..d1460dd84 100644
> --- a/mm/pagewalk.c
> +++ b/mm/pagewalk.c
> @@ -147,10 +147,18 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
> continue;
> }
>
> - if (walk->vma)
> + if (walk->vma) {
> + /*
> + * Don't descend into device-backed pfnmaps,
> + * they might refault the PMD entry.
> + */
> + if (unlikely(pmd_special(*pmd)))
> + continue;
In general, if you're using pmd_special()/pud_split() and friends in
ordinary page table walking code, you are doing something wrong. We
don't want to leak these details in such page table walkers.
We do have vm_normal_page_pmd() to identify special mappings, but I
first have to understand what exactly you are trying to solve here.
(You would also be affecting the remapping of the huge zero folio.)
A lot more details from the cover letter belong into the patch
description. In fact, you don't even need a cover letter :)
IIUC, this is rather serious and would require a Fixes: and even Cc: stable?
I'll spend some time tomorrow trying to understand what the real problem
here is.
But for now: can this only be reproduces with PUDs (which you mention in
the cover letter) or also PMDs?
For the PMD case I would assume that pte_offset_map_lock() performs
proper checks And for the PUD case we are missing a re-check under PTL.
--
Cheers,
David