From b5cdceccaa4dc20e4550cbf42ab30878f1f51b95 Mon Sep 17 00:00:00 2001 From: guenther Date: Sat, 3 May 2014 23:30:04 +0000 Subject: [PATCH] If P_ZOMBIE(pr->ps_mainproc) is true, then (pr->ps_flags & PS_EXITING) is, so eliminate the check of the former and instead use the EINVAL error for the latter. Also, consistently check for PS_EXITING before check creds. suggestion to split this from another diff miod@ --- sys/kern/kern_sysctl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 67647f82c47..2d07834f844 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.246 2014/03/30 21:54:48 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.247 2014/05/03 23:30:04 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1584,12 +1584,12 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (0); } - if (P_ZOMBIE(vp) || (vp->p_flag & P_SYSTEM)) + if (vp->p_flag & P_SYSTEM) return (EINVAL); /* Exiting - don't bother, it will be gone soon anyway */ if (vp->p_p->ps_flags & PS_EXITING) - return (ESRCH); + return (EINVAL); /* Execing - danger. */ if ((vp->p_p->ps_flags & PS_INEXEC)) @@ -1774,7 +1774,11 @@ sysctl_proc_cwd(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (0); } - if (P_ZOMBIE(findp) || (findp->p_flag & P_SYSTEM)) + if (findp->p_flag & P_SYSTEM) + return (EINVAL); + + /* Exiting - don't bother, it will be gone soon anyway */ + if (findp->p_p->ps_flags & PS_EXITING) return (EINVAL); /* Only owner or root can get cwd */ @@ -1782,10 +1786,6 @@ sysctl_proc_cwd(int *name, u_int namelen, void *oldp, size_t *oldlenp, (error = suser(cp, 0)) != 0) return (error); - /* Exiting - don't bother, it will be gone soon anyway */ - if (findp->p_p->ps_flags & PS_EXITING) - return (ESRCH); - len = *oldlenp; if (len > MAXPATHLEN * 4) len = MAXPATHLEN * 4; -- 2.20.1