git: f1cf1447e56a - stable/15 - exec: Avoid overflow when computing the size of the exec map

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a74a1c6.46255.4ae8cfbc__629.977036599882$1786028596$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=f1cf1447e56a5998c7e6db1b9668c4da77911be4

commit f1cf1447e56a5998c7e6db1b9668c4da77911be4
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-07-21 22:30:53 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-06 12:52:27 +0000

    exec: Avoid overflow when computing the size of the exec map
    
    On a test system with 1024 cores the size of exec map exceeds 4GB, and
    all of the operands in the size calculation are 32-bit integers.
    
    Tested by:      Jim Huang Chen <[email protected]>
    MFC after:      1 week
    Sponsored by:   AMD (hardware)
    
    (cherry picked from commit 2efe148a2a321d4c9ed46bdb166f710b2cb21529)
---
 sys/vm/vm_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c
index 99eb3b4a57af..d81fab854199 100644
--- a/sys/vm/vm_init.c
+++ b/sys/vm/vm_init.c
@@ -276,7 +276,7 @@ again:
 	exec_map_entry_size = round_page(PATH_MAX + ARG_MAX);
 	exec_map_guard_pages = 1;
 	TUNABLE_INT_FETCH("vm.exec_map_guard_pages", &exec_map_guard_pages);
-	size = exec_map_entries *
+	size = (vm_size_t)exec_map_entries *
 	    (exec_map_entry_size + 2 * ptoa(exec_map_guard_pages)) +
 	    64 * PAGE_SIZE;
 	kmem_subinit(exec_map, kernel_map, &minaddr, &maxaddr, size, false);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.