From: sashiko-bot@kernel.org
To: "Eliav Farber" <farbere@amazon.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: "David Hildenbrand" <david@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, "Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>,
linux-mm@kvack.org
Subject: Re: [PATCH 2/4] mm: add vmf_insert_pfn_order() and vmf_pfn_order_ok() helpers
Date: Wed, 11 Nov 2026 22:50:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-209831@kernel.org> (raw)
In-Reply-To: <20261111113045.35368-3-farbere@amazon.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] mm: missing cross-granularity zeropage checks in
vmf_insert_pfn_prot() [1]
--
commit 4d09867f23905da16cf7a825dd8a13e152a14d1e
Author: Eliav Farber <farbere@amazon.com>
mm: add vmf_insert_pfn_order() and vmf_pfn_order_ok() helpers
This commit introduces vmf_pfn_order_ok() and vmf_insert_pfn_order() to
validate fault windows and PFN alignment and to dispatch PFN insertions
across PTE, PMD, and PUD orders for VM_PFNMAP fault handlers.
> diff --git a/mm/memory.c b/mm/memory.c
> index ab29ec719ae11..0c583442e0493 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3002,6 +3002,55 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> }
> EXPORT_SYMBOL(vmf_insert_pfn);
>
> +/**
> + * vmf_insert_pfn_order - insert a pfn mapping of a given fault order
> + * @vmf: The fault being handled.
> + * @pfn: The pfn to map at the start of the order-aligned fault window.
> + * @order: The fault order (0 for a single page).
> + *
> + * Helper for ->fault and ->huge_fault handlers of VM_PFNMAP mappings: maps @pfn
> + * with a PTE for order 0, or with a PMD/PUD for PMD_ORDER/PUD_ORDER where the
> + * architecture supports huge PFN mappings. The caller must have checked the
> + * window and the pfn alignment with vmf_pfn_order_ok().
> + *
> + * vma cannot be a COW mapping.
> + *
> + * Return: vm_fault_t value; %VM_FAULT_FALLBACK if @order cannot be mapped, so
> + * that the fault is retried at a smaller order.
> + */
> +vm_fault_t vmf_insert_pfn_order(struct vm_fault *vmf, unsigned long pfn,
> + unsigned int order)
> +{
> + struct vm_area_struct *vma = vmf->vma;
> + bool write = vmf->flags & FAULT_FLAG_WRITE;
> +
> + if (!order)
> + return vmf_insert_pfn(vma, vmf->address, pfn);
> +
> + /*
> + * vmf_insert_pfn_pmd() refuses the huge zero folio's pfn with SIGBUS,
> + * while a PTE mapping of it is fine, so fall back to a smaller order.
> + */
> + if (is_huge_zero_pfn(pfn))
> + return VM_FAULT_FALLBACK;
[Severity: Critical]
This problem wasn't introduced by this patch, but can falling back to
order-0 here or dispatching to vmf_insert_pfn_pmd() and
vmf_insert_pfn_pud() below bypass zeropage checks across granularities
[1]?
Because is_huge_zero_pfn() and is_zero_pfn() match mutually exclusive PFNs,
when a huge zeropage PFN falls back to vmf_insert_pfn() ->
vmf_insert_pfn_prot() (or reaches vm_mixed_ok()), it only checks
is_zero_pfn(pfn), allowing the shared huge zeropage to be mapped writable
via PTEs and corrupted system-wide. Conversely, vmf_insert_pfn_pmd() and
vmf_insert_pfn_pud() do not check is_zero_pfn(pfn) (and
vmf_insert_pfn_pud() does not check is_huge_zero_pfn(pfn) either), so
mapping the order-0 shared zeropage at PMD or PUD granularity exposes the
surrounding physical memory within that PMD/PUD range to userspace.
[1] https://sashiko.dev/#/bug/linux-c77c75ca-4c72-4dae-8d19-e971631bb97c
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111113045.35368-1-farbere@amazon.com?part=2
next prev parent reply other threads:[~2026-11-11 22:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 11:30 [PATCH 0/4] mm, uio: huge PFN mappings for /dev/mem and UIO Eliav Farber
2026-11-11 11:30 ` [PATCH 1/4] mm: add MMAP_PFN_TRACK action and pfn_range_track() for lazy PFN maps Eliav Farber
2026-11-11 11:30 ` [PATCH 2/4] mm: add vmf_insert_pfn_order() and vmf_pfn_order_ok() helpers Eliav Farber
2026-11-11 22:50 ` sashiko-bot [this message]
2026-11-12 12:53 ` Farber, Eliav
2026-11-12 13:02 ` David Hildenbrand (Arm)
2026-11-12 15:55 ` Farber, Eliav
2026-11-11 11:30 ` [PATCH 3/4] mm/char-mem: implement huge_fault support for /dev/mem Eliav Farber
2026-11-11 22:50 ` sashiko-bot
2026-11-12 12:54 ` Farber, Eliav
2026-11-11 11:30 ` [PATCH 4/4] uio: implement huge_fault support for physical mappings Eliav Farber
2026-11-11 22:50 ` sashiko-bot
2026-11-12 12:54 ` Farber, Eliav
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=sashiko-outbox-209831@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=farbere@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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.