From eb5ea8788ff1508d7b3fdcf0254d41205c3b4ca0 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 19 Jul 2017 19:00:32 +0000 Subject: [PATCH] Disable stack growth when accessed by AIO daemons. Commit message for r321173 incorrectly stated that the change disables automatic stack growth from the AIO daemons contexts, with explanation that this is currently prevents applying wrong resource limits. Fix this by actually disabling the growth. Noted by: alc Reviewed by: alc, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/vm/vm_map.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 93ba5f21ff0c..225f522a127d 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -3698,8 +3698,15 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry) p = curproc; vm = p->p_vmspace; - if (map != &p->p_vmspace->vm_map) + + /* + * Disallow stack growth when the access is performed by a + * debugger or AIO daemon. The reason is that the wrong + * resource limits are applied. + */ + if (map != &p->p_vmspace->vm_map || p->p_textvp == NULL) return (KERN_FAILURE); + MPASS(!map->system_map); guard = stack_guard_page * PAGE_SIZE;