diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2016-03-01 16:43:09 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2016-03-01 16:43:09 +0000 |
commit | aa053fe6e77a7029329540485a5df821a4d0fee4 (patch) | |
tree | 59146c1bc27502aac6422d29b8c29f21da07ef47 /sys/dev | |
parent | 6b8431091ca21b067ef815a8c4fd98e7cedc9994 (diff) |
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')
-rw-r--r-- | sys/dev/systrace.c | 35 | ||||
-rw-r--r-- | sys/dev/systrace.h | 5 |
2 files changed, 37 insertions, 3 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; +} diff --git a/sys/dev/systrace.h b/sys/dev/systrace.h index a94d4806458..62d7e8efa78 100644 --- a/sys/dev/systrace.h +++ b/sys/dev/systrace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.h,v 1.25 2015/01/20 01:48:13 deraadt Exp $ */ +/* $OpenBSD: systrace.h,v 1.26 2016/03/01 16:43:08 naddy Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -236,5 +236,8 @@ void systrace_execve0(struct proc *); void systrace_execve1(char *, struct proc *); int systrace_scriptname(struct proc *, char *); +caddr_t stackgap_init(struct proc *); +void *stackgap_alloc(caddr_t *, size_t); + #endif /* _KERNEL */ #endif /* _SYSTRACE_H_ */ |