summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2017-05-18 18:50:33 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2017-05-18 18:50:33 +0000
commit24230fc010e8872354af312016253177b8ebe2d5 (patch)
tree327ec854e3c73cef34fc663950365ace3007fc3e /sys
parentcfe8e1e8e6e4eee1a2f2971dd47f0baedbfc182b (diff)
Add a gap of 1MB between the stack and mmap spaces.
ok deraadt@, millert@, stefan@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/exec_subr.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index de1c5fb18cc..c3784909c23 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.51 2015/08/29 05:40:01 deraadt Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.52 2017/05/18 18:50:32 kettenis Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -315,6 +315,10 @@ vmcmd_randomize(struct proc *p, struct exec_vmcmd *cmd)
return (error);
}
+#ifndef MAXSSIZ_GUARD
+#define MAXSSIZ_GUARD (1024 * 1024)
+#endif
+
/*
* exec_setup_stack(): Set up the stack segment for an executable.
*
@@ -336,7 +340,7 @@ exec_setup_stack(struct proc *p, struct exec_package *epp)
epp->ep_maxsaddr = USRSTACK;
epp->ep_minsaddr = USRSTACK + MAXSSIZ;
#else
- epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
+ epp->ep_maxsaddr = USRSTACK - MAXSSIZ - MAXSSIZ_GUARD;
epp->ep_minsaddr = USRSTACK;
#endif
epp->ep_ssize = round_page(p->p_rlimit[RLIMIT_STACK].rlim_cur);