git: 50d663b14b31 - main - vm: Fix vm_map_find_min()

From: Alan Cox <alc_at_FreeBSD.org>
Date: Wed, 26 Jul 2023 05:25:37 UTC
The branch main has been updated by alc:

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

commit 50d663b14b310d6020b4b6cc92d4fae985f086f2
Author:     Alan Cox <alc@FreeBSD.org>
AuthorDate: 2023-07-25 07:24:19 +0000
Commit:     Alan Cox <alc@FreeBSD.org>
CommitDate: 2023-07-26 05:24:50 +0000

    vm: Fix vm_map_find_min()
    
    Fix the handling of address hints that are less than min_addr by
    vm_map_find_min().
    
    Reported by:    dchagin
    Reviewed by:    kib
    Fixes:  d8e6f4946cec0 "vm: Fix anonymous memory clustering under ASLR"
    Differential Revision:  https://reviews.freebsd.org/D41159
---
 sys/vm/vm_map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 444e09986d4e..eb607d519247 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -2255,10 +2255,10 @@ vm_map_find_min(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
 	int rv;
 
 	hint = *addr;
-	if (hint == 0)
+	if (hint == 0) {
 		cow |= MAP_NO_HINT;
-	if (hint < min_addr)
 		*addr = hint = min_addr;
+	}
 	for (;;) {
 		rv = vm_map_find(map, object, offset, addr, length, max_addr,
 		    find_space, prot, max, cow);