Date: Wed, 12 Mar 2003 08:43:58 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/49963: Lack of error return for some proc sysctl's Message-ID: <200303121643.h2CGhwr4091918@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303121643.h2CGhwr4091918>