* Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
@ 2026-12-02 20:09 ` Zi Yan
2026-12-02 20:29 ` David Hildenbrand (Arm)
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Zi Yan @ 2026-12-02 20:09 UTC (permalink / raw)
To: Elkin Cruz
Cc: David Hildenbrand, Andrew Morton, Baolin Wang, Liam R. Howlett,
Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Lance Yang,
Usama Arif, Kiryl Shutsemau, linux-mm, linux-kernel, llvm,
irogers
On 2 Dec 2026, at 15:00, Elkin Cruz wrote:
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds,
> so no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
> addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> Signed-off-by: Elkin Cruz <elkin@google.com>
> ---
>
> Changes in v2:
> - Simplify checks to addr + HPAGE_{PMD,PUD}_SIZE > vma->vm_end
> (per David Hildenbrand).
>
> v1: https://lore.kernel.org/r/20261125221911.1425213-1-elkin@google.com
>
> This came up from a new Clang static analysis check for kernel bug
> classes. The fix is entirely a hardenning change :).
>
> Thanks,
> Elkin
>
> mm/huge_memory.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
LGTM.
Reviewed-by: Zi Yan <ziy@nvidia.com>
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
2026-12-02 20:09 ` Zi Yan
@ 2026-12-02 20:29 ` David Hildenbrand (Arm)
2026-12-02 20:45 ` + mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch added to mm-new branch Andrew Morton
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 20:29 UTC (permalink / raw)
To: Elkin Cruz, Zi Yan, Andrew Morton
Cc: Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Kiryl Shutsemau, linux-mm,
linux-kernel, llvm, irogers
On 12/2/26 21:00, Elkin Cruz wrote:
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds,
> so no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
> addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> Signed-off-by: Elkin Cruz <elkin@google.com>
> ---
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread* + mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch added to mm-new branch
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
2026-12-02 20:09 ` Zi Yan
2026-12-02 20:29 ` David Hildenbrand (Arm)
@ 2026-12-02 20:45 ` Andrew Morton
2026-12-03 7:58 ` David Hildenbrand (Arm)
2026-12-03 6:04 ` [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Barry Song
` (3 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2026-12-02 20:45 UTC (permalink / raw)
To: mm-commits, ziy, usama.arif, ryan.roberts, nico.pache, liam,
lance.yang, kas, irogers, dev.jain, david, baolin.wang, baohua,
elkin, akpm
The patch titled
Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
has been added to the -mm mm-new branch. Its filename is
mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Elkin Cruz <elkin@google.com>
Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
Date: Wed, 02 Dec 2026 20:00:56 +0000
insert_pmd() and insert_pud() currently check only that addr lies within
[vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
mapping fits below vma->vm_end.
All current in-tree callers already validate VMA end alignment/bounds, so
no existing user triggers this. Harden both helpers defensively by
requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and addr +
HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
Link: https://patch.msgid.link/20261202200056.3555477-1-elkin@google.com
Signed-off-by: Elkin Cruz <elkin@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Ian Rogers <irogers@google.com>
mm/huge_memory.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/mm/huge_memory.c~mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud
+++ a/mm/huge_memory.c
@@ -1630,7 +1630,7 @@ static vm_fault_t insert_pmd(struct vm_a
spinlock_t *ptl;
pmd_t entry;
- if (addr < vma->vm_start || addr >= vma->vm_end)
+ if (addr < vma->vm_start || addr + HPAGE_PMD_SIZE > vma->vm_end)
return VM_FAULT_SIGBUS;
if (arch_needs_pgtable_deposit()) {
@@ -1768,7 +1768,7 @@ static vm_fault_t insert_pud(struct vm_a
spinlock_t *ptl;
pud_t entry;
- if (addr < vma->vm_start || addr >= vma->vm_end)
+ if (addr < vma->vm_start || addr + HPAGE_PUD_SIZE > vma->vm_end)
return VM_FAULT_SIGBUS;
ptl = pud_lock(mm, pud);
_
Patches currently in -mm which might be from elkin@google.com are
mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: + mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch added to mm-new branch
2026-12-02 20:45 ` + mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch added to mm-new branch Andrew Morton
@ 2026-12-03 7:58 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-03 7:58 UTC (permalink / raw)
To: Andrew Morton, mm-commits, ziy, usama.arif, ryan.roberts,
nico.pache, liam, lance.yang, kas, irogers, dev.jain, baolin.wang,
baohua, elkin
On 12/2/26 21:45, Andrew Morton wrote:
> The patch titled
> Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
> has been added to the -mm mm-new branch. Its filename is
> mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
>
> This patch will shortly appear at
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
>
> This patch will later appear in the mm-new branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
>
> Note, mm-new is a provisional staging ground for work-in-progress
> patches, and acceptance into mm-new is a notification for others take
> notice and to finish up reviews. Please do not hesitate to respond to
> review feedback and post updated versions to replace or incrementally
> fixup patches in mm-new.
>
> The mm-new branch of mm.git is not included in linux-next
>
> If a few days of testing in mm-new is successful, the patch will me moved
> into mm.git's mm-unstable branch, which is included in linux-next
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next via various
> branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there most days
>
> ------------------------------------------------------
> From: Elkin Cruz <elkin@google.com>
> Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
> Date: Wed, 02 Dec 2026 20:00:56 +0000
>
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds, so
> no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and addr +
> HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> Link: https://patch.msgid.link/20261202200056.3555477-1-elkin@google.com
> Signed-off-by: Elkin Cruz <elkin@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Liam R. Howlett <liam@infradead.org>
> Cc: Nico Pache <nico.pache@linux.dev>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Barry Song <baohua@kernel.org>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Usama Arif <usama.arif@linux.dev>
> Cc: Kiryl Shutsemau <kas@kernel.org>
> Cc: Ian Rogers <irogers@google.com>
>
> mm/huge_memory.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Will take this through my tree.
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
` (2 preceding siblings ...)
2026-12-02 20:45 ` + mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch added to mm-new branch Andrew Morton
@ 2026-12-03 6:04 ` Barry Song
2026-12-03 8:29 ` David Hildenbrand
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Barry Song @ 2026-12-03 6:04 UTC (permalink / raw)
To: Elkin Cruz
Cc: David Hildenbrand, Zi Yan, Andrew Morton, Baolin Wang,
Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Lance Yang,
Usama Arif, Kiryl Shutsemau, linux-mm, linux-kernel, llvm,
irogers
On Thu, Dec 3, 2026 at 4:01 AM Elkin Cruz <elkin@google.com> wrote:
>
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds,
> so no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
> addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> Signed-off-by: Elkin Cruz <elkin@google.com>
> ---
Reviewed-by: Barry Song <baohua@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
` (3 preceding siblings ...)
2026-12-03 6:04 ` [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Barry Song
@ 2026-12-03 8:29 ` David Hildenbrand
2026-12-03 16:32 ` [-] mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch removed from -mm tree Andrew Morton
2026-12-04 8:55 ` [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Baolin Wang
6 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand @ 2026-12-03 8:29 UTC (permalink / raw)
To: David Hildenbrand, Zi Yan, Andrew Morton, Elkin Cruz
Cc: Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Barry Song, Lance Yang, Usama Arif, Kiryl Shutsemau, linux-mm,
linux-kernel, llvm, irogers
On Wed, 02 Dec 2026 20:00:56 +0000, Elkin Cruz wrote:
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds,
> so no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
> addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> [...]
Applied, thanks!
tree: mm/core.git
branch: thp-7.5.misc
Applied patches will appear soon in mm-next, followed by linux-next.
Please report any outstanding bugs that were missed during review, so we
can either drop the patch series or decide how to fix it up.
It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even
though the patches have already been applied. If possible, patch trailers
will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. Further, this is not a guarantee that the
patches will go upstream. If in doubt, please check the listed branch.
[1/1] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
https://git.kernel.org/mm/core/c/814f1a29
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread* [-] mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch removed from -mm tree
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
` (4 preceding siblings ...)
2026-12-03 8:29 ` David Hildenbrand
@ 2026-12-03 16:32 ` Andrew Morton
2026-12-04 8:55 ` [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Baolin Wang
6 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-12-03 16:32 UTC (permalink / raw)
To: mm-commits, ziy, usama.arif, ryan.roberts, nico.pache, liam,
lance.yang, kas, irogers, dev.jain, david, baolin.wang, baohua,
elkin, akpm
The quilt patch titled
Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
has been removed from the -mm tree. Its filename was
mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch
This patch was dropped because David is taking it
------------------------------------------------------
From: Elkin Cruz <elkin@google.com>
Subject: mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
Date: Wed, 02 Dec 2026 20:00:56 +0000
insert_pmd() and insert_pud() currently check only that addr lies within
[vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
mapping fits below vma->vm_end.
All current in-tree callers already validate VMA end alignment/bounds, so
no existing user triggers this. Harden both helpers defensively by
requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and addr +
HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
Link: https://patch.msgid.link/20261202200056.3555477-1-elkin@google.com
Signed-off-by: Elkin Cruz <elkin@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Ian Rogers <irogers@google.com>
mm/huge_memory.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/mm/huge_memory.c~mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud
+++ a/mm/huge_memory.c
@@ -1630,7 +1630,7 @@ static vm_fault_t insert_pmd(struct vm_a
spinlock_t *ptl;
pmd_t entry;
- if (addr < vma->vm_start || addr >= vma->vm_end)
+ if (addr < vma->vm_start || addr + HPAGE_PMD_SIZE > vma->vm_end)
return VM_FAULT_SIGBUS;
if (arch_needs_pgtable_deposit()) {
@@ -1768,7 +1768,7 @@ static vm_fault_t insert_pud(struct vm_a
spinlock_t *ptl;
pud_t entry;
- if (addr < vma->vm_start || addr >= vma->vm_end)
+ if (addr < vma->vm_start || addr + HPAGE_PUD_SIZE > vma->vm_end)
return VM_FAULT_SIGBUS;
ptl = pud_lock(mm, pud);
_
Patches currently in -mm which might be from elkin@google.com are
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud()
2026-12-02 20:00 [PATCH v2] mm/huge_memory: check VMA end bounds in insert_pmd() and insert_pud() Elkin Cruz
` (5 preceding siblings ...)
2026-12-03 16:32 ` [-] mm-huge_memory-check-vma-end-bounds-in-insert_pmd-and-insert_pud.patch removed from -mm tree Andrew Morton
@ 2026-12-04 8:55 ` Baolin Wang
6 siblings, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2026-12-04 8:55 UTC (permalink / raw)
To: Elkin Cruz, David Hildenbrand, Zi Yan, Andrew Morton
Cc: Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Barry Song,
Lance Yang, Usama Arif, Kiryl Shutsemau, linux-mm, linux-kernel,
llvm, irogers
On 12/3/26 4:00 AM, Elkin Cruz wrote:
> insert_pmd() and insert_pud() currently check only that addr lies within
> [vma->vm_start, vma->vm_end), without verifying that the full PMD or PUD
> mapping fits below vma->vm_end.
>
> All current in-tree callers already validate VMA end alignment/bounds,
> so no existing user triggers this. Harden both helpers defensively by
> requiring addr + HPAGE_PMD_SIZE <= vma->vm_end in insert_pmd() and
> addr + HPAGE_PUD_SIZE <= vma->vm_end in insert_pud().
>
> Signed-off-by: Elkin Cruz <elkin@google.com>
> ---
LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
^ permalink raw reply [flat|nested] 9+ messages in thread