summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsemarie <semarie@openbsd.org>2015-10-26 07:44:43 +0000
committersemarie <semarie@openbsd.org>2015-10-26 07:44:43 +0000
commit3775e79e5e0ae39f4d8782e1bfc872609b4a39af (patch)
tree0e61e34ee9ae8cedafe615ce2118ab903b9d0e50
parentmake pledge_check(), used for syscall check with pledge, returns an error and (diff)
downloadwireguard-openbsd-3775e79e5e0ae39f4d8782e1bfc872609b4a39af.tar.xz
wireguard-openbsd-3775e79e5e0ae39f4d8782e1bfc872609b4a39af.zip
change some pledge_fail() error/code
- for PLEDGE_FATTR: the code is more accurate to be PLEDGE_FATTR, has p->p_pledgenote could have multiple bits inside, and it is the lake of PLEDGE_FATTR that make the check fail. - for PLEDGE_RECVFD and PLEDGE_SENDFD, change the error to be EINVAL: we fail, not because of lake of PLEDGE_RECVFD / PLEDGE_SENDFD permission, but because the value passed is invalid in pledged program (for example trying to send a VDIR). "go ahead" deraadt@
-rw-r--r--sys/kern/kern_pledge.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c
index 1f8a029c59c..adf42cdb073 100644
--- a/sys/kern/kern_pledge.c
+++ b/sys/kern/kern_pledge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_pledge.c,v 1.75 2015/10/26 07:24:20 semarie Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.76 2015/10/26 07:44:43 semarie Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -546,7 +546,7 @@ pledge_namei(struct proc *p, char *origpath)
/* chmod(2), chflags(2), ... */
if ((p->p_pledgenote & PLEDGE_FATTR) &&
(p->p_p->ps_pledge & PLEDGE_FATTR) == 0) {
- return (pledge_fail(p, EPERM, p->p_pledgenote));
+ return (pledge_fail(p, EPERM, PLEDGE_FATTR));
}
/* Detect what looks like a mkstemp(3) family operation */
@@ -822,7 +822,7 @@ pledge_recvfd_check(struct proc *p, struct file *fp)
break;
}
printf("recvfd type %d %s\n", fp->f_type, vp ? vtypes[vp->v_type] : "");
- return pledge_fail(p, EPERM, PLEDGE_RECVFD);
+ return pledge_fail(p, EINVAL, PLEDGE_RECVFD);
}
/*
@@ -854,7 +854,7 @@ pledge_sendfd_check(struct proc *p, struct file *fp)
break;
}
printf("sendfd type %d %s\n", fp->f_type, vp ? vtypes[vp->v_type] : "");
- return pledge_fail(p, EPERM, PLEDGE_SENDFD);
+ return pledge_fail(p, EINVAL, PLEDGE_SENDFD);
}
int