* + mm-vmalloc-reject-overflowing-vm_map_ram-page-counts.patch added to mm-new branch
@ 2026-11-10 4:06 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-10 4:06 UTC (permalink / raw)
To: mm-commits, urezki, stable, shubhang, npiggin, dev.jain, cl,
anshuman.khandual, sh, akpm
The patch titled
Subject: mm/vmalloc: reject overflowing vm_map_ram page counts
has been added to the -mm mm-new branch. Its filename is
mm-vmalloc-reject-overflowing-vm_map_ram-page-counts.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmalloc-reject-overflowing-vm_map_ram-page-counts.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: "Shubhang Kaushik (Ampere)" <sh@gentwo.org>
Subject: mm/vmalloc: reject overflowing vm_map_ram page counts
Date: Thu, 22 Oct 2026 23:43:47 -0700
vm_map_ram() accepts a page count and must either map that many pages or
fail. It currently converts the count to a byte size with:
(unsigned long)count << PAGE_SHIFT
On 32-bit kernels, this conversion overflows when count is greater than
ULONG_MAX >> PAGE_SHIFT. vm_map_ram() then allocates and maps only the
wrapped byte size, but returns a non-NULL address to its caller.
For example, with 4 KiB pages, a count of 1048577 wraps to PAGE_SIZE.
vm_map_ram() therefore returns a mapping containing one page instead of
the requested 1048577 pages.
If a caller uses the successful result as a mapping of all requested
pages, it can access beyond the allocated mapping. Such an access can
fault. If the accessed virtual address is occupied by another vmalloc
mapping, it can instead access and corrupt unrelated kernel memory. In a
userspace-reachable call path, this can result in a failed operation, a
kernel oops or panic, or the effects of corrupted kernel data.
Return NULL before allocating or mapping anything when count * PAGE_SIZE
cannot be represented in an unsigned long.
Link: https://lore.kernel.org/20261022-vmalloc-reject-overflow-v2-1-0db7a20c53f0@gentwo.org
Fixes: db64fe02258f ("mm: rewrite vmap layer")
Signed-off-by: Shubhang Kaushik (Ampere) <sh@gentwo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Shubhang Kaushik <shubhang@os.amperecomputing.com>
Cc: Christoph Lameter (Ampere) <cl@gentwo.org>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: <stable@vger.kernel.org>
---
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/mm/vmalloc.c~mm-vmalloc-reject-overflowing-vm_map_ram-page-counts
+++ a/mm/vmalloc.c
@@ -3160,10 +3160,13 @@ EXPORT_SYMBOL(vm_unmap_ram);
*/
void *vm_map_ram(struct page **pages, unsigned int count, int node)
{
- unsigned long size = (unsigned long)count << PAGE_SHIFT;
+ unsigned long size;
unsigned long addr;
void *mem;
+ if (check_mul_overflow((unsigned long)count, PAGE_SIZE, &size))
+ return NULL;
+
if (likely(count <= VMAP_MAX_ALLOC)) {
mem = vb_alloc(size, GFP_KERNEL);
if (IS_ERR(mem))
_
Patches currently in -mm which might be from sh@gentwo.org are
mm-damon-ops-common-align-mmu-notifier-range-when-clearing-pte-young-bit.patch
mm-vmalloc-reject-overflowing-vm_map_ram-page-counts.patch
ipc-msg-fix-msg_qbytes-truncation-in-ipc_set.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-10 4:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 4:06 + mm-vmalloc-reject-overflowing-vm_map_ram-page-counts.patch added to mm-new branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox