Permalink
Browse files

restrict KERN_PROC_ARGS lookup of KERN_PROC_NENV and KERN_PROC_ENV

to process owner and root

ok deraadt millert guenther
  • Loading branch information...
jcs committed Jan 15, 2013
1 parent c73f1fe commit 11f493506dad9d0fa6232ac87c7ee1738b9d4ea4
Showing with 7 additions and 1 deletion.
  1. +7 −1 sys/kern/kern_sysctl.c
View
@@ -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++;

0 comments on commit 11f4935

Please sign in to comment.