diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2023-07-25 18:52:15 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-08-12 06:28:13 +0000 |
commit | b6037edbd17dd3144aa1a7b0814cd5ebe98d765a (patch) | |
tree | a939f9be5d84269055bf0fa58ca2a11f3fe27b80 /sys/vm | |
parent | 9d7ea6cff7a7edc0f3d4fa8d54e6345ee027e754 (diff) | |
download | src-b6037edbd17dd3144aa1a7b0814cd5ebe98d765a.tar.gz src-b6037edbd17dd3144aa1a7b0814cd5ebe98d765a.zip |
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
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 10 |
1 files 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); |