From owner-freebsd-bugs Wed Mar 12 8:50: 9 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D043037B401 for ; Wed, 12 Mar 2003 08:50:06 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0DA243F85 for ; Wed, 12 Mar 2003 08:50:05 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h2CGo5NS096199 for ; Wed, 12 Mar 2003 08:50:05 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h2CGo5aX096198; Wed, 12 Mar 2003 08:50:05 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C5F637B401 for ; Wed, 12 Mar 2003 08:43:59 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D677043F85 for ; Wed, 12 Mar 2003 08:43:58 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: from freefall.freebsd.org (jhb@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h2CGhwNS091969 for ; Wed, 12 Mar 2003 08:43:58 -0800 (PST) (envelope-from jhb@freefall.freebsd.org) Received: (from jhb@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h2CGhwr4091918; Wed, 12 Mar 2003 08:43:58 -0800 (PST) Message-Id: <200303121643.h2CGhwr4091918@freefall.freebsd.org> Date: Wed, 12 Mar 2003 08:43:58 -0800 (PST) From: John Baldwin Reply-To: John Baldwin To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/49963: Lack of error return for some proc sysctl's Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 49963 >Category: kern >Synopsis: Lack of error return for some proc sysctl's >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 12 08:50:05 PST 2003 >Closed-Date: >Last-Modified: >Originator: John Baldwin >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD laptop.baldwin.cx 5.0-CURRENT FreeBSD 5.0-CURRENT #799: Mon Mar 10 17:09:27 EST 2003 root@laptop.baldwin.cx:/usr/src/sys/i386/compile/LAPTOP i386 >Description: In /sys/kern/kern_proc.c sysctl_kern_proc() and sysctl_kern_proc_args() the functions return 0 (success) if we fail to find a process asked for by a specific PID or if p_cansee() fails for the process. It would seem more intuitive to return ESRCH in those cases instead. >How-To-Repeat: >Fix: Index: kern_proc.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_proc.c,v retrieving revision 1.174 diff -u -r1.174 kern_proc.c --- kern_proc.c 12 Mar 2003 16:14:55 -0000 1.174 +++ kern_proc.c 12 Mar 2003 16:43:04 -0000 @@ -865,10 +865,10 @@ return (EINVAL); p = pfind((pid_t)name[0]); if (!p) - return (0); + return (ESRCH); if (p_cansee(curthread, p)) { PROC_UNLOCK(p); - return (0); + return (ESRCH); } error = sysctl_out_proc(p, req, 0); return (error); @@ -1033,11 +1033,11 @@ p = pfind((pid_t)name[0]); if (!p) - return (0); + return (ESRCH); if ((!ps_argsopen) && p_cansee(curthread, p)) { PROC_UNLOCK(p); - return (0); + return (ESRCH); } if (req->newptr && curproc != p) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message