From 68511280041637921c144dadc66364bd3847520e Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Sun, 1 Nov 2015 19:03:34 +0000 Subject: 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@ --- sys/kern/kern_sig.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'sys/kern/kern_sig.c') diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 677a35e3da5..7f49043214a 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.187 2015/10/25 20:39:54 deraadt Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.188 2015/11/01 19:03:33 semarie Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -569,16 +569,10 @@ sys_kill(struct proc *cp, void *v, register_t *retval) struct proc *p; int pid = SCARG(uap, pid); int signum = SCARG(uap, signum); + int error; - if (cp->p_p->ps_flags & PS_PLEDGE) { - /* PLEDGE_PROC is required to signal another pid */ - if ((cp->p_p->ps_pledge & PLEDGE_PROC) || - pid == cp->p_pid || pid == 0) - ; - else - return pledge_fail(cp, EPERM, PLEDGE_PROC); - } - + if ((error = pledge_kill(cp, pid)) != 0) + return (error); if (((u_int)signum) >= NSIG) return (EINVAL); if (pid > 0) { -- cgit v1.2.3