Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Aug 2023 01:08:36 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f60811fed642 - stable/13 - vm_map_growstack(): restore stack gap data if gap entry was removed
Message-ID:  <202308250108.37P18aca058468@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

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

commit f60811fed6428ebf75c888aec67e71714b75e618
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-07-25 18:52:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-25 01:06:44 +0000

    vm_map_growstack(): restore stack gap data if gap entry was removed
    
    (cherry picked from commit b6037edbd17dd3144aa1a7b0814cd5ebe98d765a)
---
 sys/vm/vm_map.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 076528126e44..1f223bbbd396 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -4658,7 +4658,7 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry)
 	struct vmspace *vm;
 	struct ucred *cred;
 	vm_offset_t gap_end, gap_start, grow_start;
-	vm_size_t grow_amount, guard, max_grow;
+	vm_size_t grow_amount, guard, max_grow, sgp;
 	vm_prot_t prot, max;
 	rlim_t lmemlim, stacklim, vmemlim;
 	int rv, rv1;
@@ -4806,6 +4806,7 @@ retry:
 		 */
 		prot = PROT_EXTRACT(gap_entry->offset);
 		max = PROT_MAX_EXTRACT(gap_entry->offset);
+		sgp = gap_entry->next_read;
 
 		grow_start = gap_entry->end - grow_amount;
 		if (gap_entry->start + grow_amount == gap_entry->end) {
@@ -4822,10 +4823,13 @@ retry:
 		    grow_start + grow_amount, prot, max, MAP_STACK_GROWS_DOWN);
 		if (rv != KERN_SUCCESS) {
 			if (gap_deleted) {
-				rv1 = vm_map_insert(map, NULL, 0, gap_start,
+				rv1 = vm_map_insert1(map, NULL, 0, gap_start,
 				    gap_end, VM_PROT_NONE, VM_PROT_NONE,
-				    MAP_CREATE_GUARD | MAP_CREATE_STACK_GAP_DN);
+				    MAP_CREATE_GUARD | MAP_CREATE_STACK_GAP_DN,
+				    &gap_entry);
 				MPASS(rv1 == KERN_SUCCESS);
+				gap_entry->next_read = sgp;
+				gap_entry->offset = prot | PROT_MAX(max);
 			} else
 				vm_map_entry_resize(map, gap_entry,
 				    grow_amount);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308250108.37P18aca058468>