summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorSebastien Marie <semarie@cvs.openbsd.org>2015-11-01 19:03:34 +0000
committerSebastien Marie <semarie@cvs.openbsd.org>2015-11-01 19:03:34 +0000
commit68511280041637921c144dadc66364bd3847520e (patch)
tree8837690b527988d8389c4243559c191b02100459 /sys/uvm
parentb249aebdcb012545f1aa7bab683224c46dc508fc (diff)
refactor pledge_*_check and pledge_fail functions
- rename _check function without suffix: a "pledge" function called from anywhere is a "check" function. - makes pledge_fail call the responsability to the _check function. remove it from caller. - make proper use of (potential) returned error of _check() functions. - adds pledge_kill() and pledge_protexec() with and OK deraadt@
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_mmap.c17
-rw-r--r--sys/uvm/uvm_swap.c4
2 files changed, 10 insertions, 11 deletions
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index 5f177abdb94..7ebc6e42145 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_mmap.c,v 1.120 2015/10/09 01:10:27 deraadt Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.121 2015/11/01 19:03:33 semarie Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -365,10 +365,9 @@ sys_mmap(struct proc *p, void *v, register_t *retval)
if (size == 0)
return (EINVAL);
- if ((p->p_p->ps_flags & PS_PLEDGE) &&
- !(p->p_p->ps_pledge & PLEDGE_PROTEXEC) &&
- (prot & PROT_EXEC))
- return (pledge_fail(p, EPERM, PLEDGE_PROTEXEC));
+ error = pledge_protexec(p, prot);
+ if (error)
+ return (error);
/* align file position and save offset. adjust size. */
ALIGN_ADDR(pos, size, pageoff);
@@ -656,6 +655,7 @@ sys_mprotect(struct proc *p, void *v, register_t *retval)
vaddr_t addr;
vsize_t size, pageoff;
vm_prot_t prot;
+ int error;
/*
* extract syscall args from uap
@@ -668,10 +668,9 @@ sys_mprotect(struct proc *p, void *v, register_t *retval)
if ((prot & PROT_MASK) != prot)
return (EINVAL);
- if ((p->p_p->ps_flags & PS_PLEDGE) &&
- !(p->p_p->ps_pledge & PLEDGE_PROTEXEC) &&
- (prot & PROT_EXEC))
- return (pledge_fail(p, EPERM, PLEDGE_PROTEXEC));
+ error = pledge_protexec(p, prot);
+ if (error)
+ return (error);
/*
* align the address to a page boundary, and adjust the size accordingly
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index f7fa31d28dd..a2a3ad80226 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.138 2015/10/23 01:10:01 deraadt Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.139 2015/11/01 19:03:33 semarie Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
@@ -670,7 +670,7 @@ sys_swapctl(struct proc *p, void *v, register_t *retval)
}
/* all other requests require superuser privs. verify. */
- if ((error = suser(p, 0)) || pledge_swapctl_check(p))
+ if ((error = suser(p, 0)) || (error = pledge_swapctl(p)))
goto out;
/*