summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorjoshua stein <jcs@cvs.openbsd.org>2013-01-15 23:30:40 +0000
committerjoshua stein <jcs@cvs.openbsd.org>2013-01-15 23:30:40 +0000
commit96117128c3f12a81d16a0465148e43bbafac4b4e (patch)
treecff8df176351338d76c2752d129198457a64b797 /sys
parent764848d7a3228f5177941ebbe5cebb373389146c (diff)
restrict KERN_PROC_ARGS lookup of KERN_PROC_NENV and KERN_PROC_ENV
to process owner and root ok deraadt millert guenther
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 1ff334cc116..625de44c291 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.229 2012/12/30 00:58:19 guenther Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.230 2013/01/15 23:30:39 jcs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -1608,6 +1608,12 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp,
/* Execing - danger. */
if ((vp->p_p->ps_flags & PS_INEXEC))
return (EBUSY);
+
+ /* Only owner or root can get env */
+ if ((op == KERN_PROC_NENV || op == KERN_PROC_ENV) &&
+ (vp->p_ucred->cr_uid != cp->p_ucred->cr_uid &&
+ (error = suser(cp, 0)) != 0))
+ return (error);
vm = vp->p_vmspace;
vm->vm_refcnt++;