The branch main has been updated by jrtc27:

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

commit 4015ff43cbbe819316104258da6a79bef76e52c2
Author:     Jessica Clarke <jrt...@freebsd.org>
AuthorDate: 2025-01-31 18:37:27 +0000
Commit:     Jessica Clarke <jrt...@freebsd.org>
CommitDate: 2025-01-31 18:37:27 +0000

    vm: Fix overflow issues in vm_page_startup
    
    Firstly, pagecount is a u_long so we should ensure j is the same for the
    sake of 64-bit systems. Secondly, ptoa is just a macro, and does not
    cast its argument, so in order to handle PAE systems correctly we need
    to cast j to vm_paddr_t (the type of startp).
    
    Fixes:  0078df5f0258 ("vm_phys: reduce touching of page->pool fields")
---
 sys/vm/vm_page.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 961b32da6599..f0e3fc73fb34 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -836,9 +836,10 @@ vm_page_startup(vm_offset_t vaddr)
                        m = vm_phys_seg_paddr_to_vm_page(seg, startp);
                        vm_page_init_page(m, startp, segind, pool);
                        if (pool == VM_FREEPOOL_DEFAULT) {
-                               for (int j = 1; j < pagecount; j++) {
+                               for (u_long j = 1; j < pagecount; j++) {
                                        vm_page_init_page(&m[j],
-                                           startp + ptoa(j), segind, pool);
+                                           startp + ptoa((vm_paddr_t)j),
+                                           segind, pool);
                                }
                        }
                        vmd = VM_DOMAIN(seg->domain);

Reply via email to