summaryrefslogtreecommitdiffstats
path: root/sys/dev/systrace.c
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2016-03-01 16:43:08 +0000
committernaddy <naddy@openbsd.org>2016-03-01 16:43:08 +0000
commit4420e0ddea003df17a2c6b693516cce22eebfa88 (patch)
treef9fbe6da60d6e949243070bebcd6a8f6a290effd /sys/dev/systrace.c
parentdrop Linux emulation support; ok sthen@ visa@ (diff)
downloadwireguard-openbsd-4420e0ddea003df17a2c6b693516cce22eebfa88.tar.xz
wireguard-openbsd-4420e0ddea003df17a2c6b693516cce22eebfa88.zip
Copy the stackgap_init() and stackgap_alloc() functions from
compat/common/compat_util.c to dev/systrace.c, the one place they are used, and remove the remaining kernel references to compat/*. ok visa@
Diffstat (limited to 'sys/dev/systrace.c')
-rw-r--r--sys/dev/systrace.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c
index 9b03bc21c01..05eef15dfa7 100644
--- a/sys/dev/systrace.c
+++ b/sys/dev/systrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: systrace.c,v 1.77 2015/09/08 11:58:58 deraadt Exp $ */
+/* $OpenBSD: systrace.c,v 1.78 2016/03/01 16:43:08 naddy Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -48,7 +48,8 @@
#include <sys/poll.h>
#include <sys/ptrace.h>
-#include <compat/common/compat_util.h>
+#include <sys/exec.h>
+#include <uvm/uvm_extern.h>
#include <dev/systrace.h>
@@ -1811,3 +1812,33 @@ systrace_msg_policyfree(struct fsystrace *fst, struct str_policy *strpol)
return (0);
}
+
+caddr_t
+stackgap_init(struct proc *p)
+{
+ struct process *pr = p->p_p;
+
+ if (pr->ps_stackgap == 0) {
+ if (uvm_map(&pr->ps_vmspace->vm_map, &pr->ps_stackgap,
+ round_page(STACKGAPLEN), NULL, 0, 0,
+ UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
+ MAP_INHERIT_COPY, MADV_RANDOM, UVM_FLAG_COPYONW)))
+ sigexit(p, SIGILL);
+ }
+
+ return (caddr_t)pr->ps_stackgap;
+}
+
+void *
+stackgap_alloc(caddr_t *sgp, size_t sz)
+{
+ void *n = (void *) *sgp;
+ caddr_t nsgp;
+
+ sz = ALIGN(sz);
+ nsgp = *sgp + sz;
+ if (nsgp > (caddr_t)trunc_page((vaddr_t)n) + STACKGAPLEN)
+ return NULL;
+ *sgp = nsgp;
+ return n;
+}