git: b6037edbd17d - main - vm_map_growstack(): restore stack gap data if gap entry was removed
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 12 Aug 2023 06:29:11 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b6037edbd17dd3144aa1a7b0814cd5ebe98d765a
commit b6037edbd17dd3144aa1a7b0814cd5ebe98d765a
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-07-25 18:52:15 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-12 06:28:13 +0000
vm_map_growstack(): restore stack gap data if gap entry was removed
and then restored.
Reviewed by: alc, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41099
---
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 790d81bba44b..1c806d6cae34 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -4657,7 +4657,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 __diagused;
@@ -4805,6 +4805,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) {
@@ -4821,10 +4822,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);