From owner-freebsd-bugs Sat Aug 18 4: 0:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 10F0337B411 for ; Sat, 18 Aug 2001 04:00:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f7IB03h41648; Sat, 18 Aug 2001 04:00:03 -0700 (PDT) (envelope-from gnats) Received: from mgate05.so-net.ne.jp (mgate05.so-net.ne.jp [210.139.254.152]) by hub.freebsd.org (Postfix) with ESMTP id C0F0437B410 for ; Sat, 18 Aug 2001 03:57:37 -0700 (PDT) (envelope-from sanewo@ba2.so-net.ne.jp) Received: from mail.ba2.so-net.ne.jp (mspool12.so-net.ne.jp [210.139.248.12]) by mgate05.so-net.ne.jp (8.8.8+3.0Wbeta9/3.6W01060506) with ESMTP id TAA14987 for ; Sat, 18 Aug 2001 19:57:36 +0900 (JST) Received: from ba2.so-net.ne.jp (pd301e9.tkyoea00.ap.so-net.ne.jp [61.211.1.233]) by mail.ba2.so-net.ne.jp with ESMTP id f7IAvZV17400 for ; Sat, 18 Aug 2001 19:57:35 +0900 (JST) Received: (from sanewo@localhost) by ba2.so-net.ne.jp (8.11.5/8.11.5) id f7IAvYU79589; Sat, 18 Aug 2001 19:57:34 +0900 (JST) (envelope-from sanewo) Message-Id: <200108181057.f7IAvYU79589@ba2.so-net.ne.jp> Date: Sat, 18 Aug 2001 19:57:34 +0900 (JST) From: Takanori Saneto To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/29844: setpgrp does not behave as manual says 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: 29844 >Category: kern >Synopsis: setpgrp does not behave as manual says >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Aug 18 04:00:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Takanori Saneto >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD muse.sanewo 5.0-CURRENT FreeBSD 5.0-CURRENT #8: Sat Aug 18 13:15:18 JST 2001 root@:/export/usr.obj/usr/src/sys/MUSE i386 Confirmed on 5.0-CURRENT as of today and 4.3-STABLE as of Jul 29 2001. By checking the source, I believe that this bug was in 4.4BSD-Lite as well. >Description: As superuser, setpgrp(1,1) fails (errno=ESRCH). setpgrp(2) says: If the invoker is not the super-user, then the affected process must have the same effective user-id as the invoker or be a descendant of the invoking process. Actually, document says nothing about what should happen when the invoker is the super-user. So it might not be a software bug, but a poor documentation... >How-To-Repeat: Compile following program: main() { if (setpgrp(1,1) < 0) perror("setpgrp"); } and run it as root. >Fix: 1. Fix the document --- setpgid.2.orig Sat Aug 18 19:53:12 2001 +++ setpgid.2 Sat Aug 18 19:53:34 2001 @@ -57,7 +57,7 @@ .Fa pid is zero, then the call applies to the current process. .Pp -If the invoker is not the super-user, then the affected process +Affected process must have the same effective user-id as the invoker or be a descendant of the invoking process. .Sh RETURN VALUES Or 2. Fix the kernel source --- kern_prot.c.orig Sat Aug 18 19:54:23 2001 +++ kern_prot.c Sat Aug 18 19:54:57 2001 @@ -368,7 +368,7 @@ if (uap->pgid < 0) return (EINVAL); if (uap->pid != 0 && uap->pid != curp->p_pid) { - if ((targp = pfind(uap->pid)) == NULL || !inferior(targp)) { + if ((targp = pfind(uap->pid)) == NULL || (!suser(curp) && !inferior(targp))) { if (targp) PROC_UNLOCK(targp); return (ESRCH); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message