From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 4 11:49:13 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D92816A4CE; Tue, 4 Nov 2003 11:49:13 -0800 (PST) Received: from sweeper.openet-telecom.com (mail.openet-telecom.com [62.17.151.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19D9B43FD7; Tue, 4 Nov 2003 11:49:11 -0800 (PST) (envelope-from peter.edwards@openet-telecom.com) Received: from mail.openet-telecom.com (unverified) by sweeper.openet-telecom.com ; Tue, 4 Nov 2003 19:50:12 +0000 Received: from openet-telecom.com (10.0.0.40) by mail.openet-telecom.com (NPlex 6.5.027) (authenticated as peter.edwards@openet-telecom.com) id 3FA62F9800001E8F; Tue, 4 Nov 2003 19:44:35 +0000 Message-ID: <3FA802AF.4030107@openet-telecom.com> Date: Tue, 04 Nov 2003 19:49:03 +0000 From: Peter Edwards User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031104 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Schultz References: <3FA61A17.70605@turtle.freedns.us> <20031104081800.GA78439@VARK.homeunix.com> <3FA76D43.1040508@turtle.freedns.us> <20031104191526.GA79079@VARK.homeunix.com> In-Reply-To: <20031104191526.GA79079@VARK.homeunix.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: FreeBSD Hackers cc: FreeBSD Bugs cc: Igor Serikov Subject: Re: rfork problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2003 19:49:13 -0000 David Schultz wrote: >On Tue, Nov 04, 2003, Igor Serikov wrote: > > >> David, >> >>Is it okay to have a condition that can be created by a mortal user and >>then cannot be changed by the root? The waiting process cannot be killed >>and would keep "waiting" till system reboot. >> >> > >Aah, I see. No, it's not okay that a non-root user can create an >unkillable process. -CURRENT doesn't have this problem because it >rightly fails when a userland program tries to use RFPPWAIT. (It >isn't supposed to be available to userland, which is why it isn't >documented.) The problem could be fixed by backporting the >relevant bits from -CURRENT. > > > >>I do not think it is a good idea to make ppwait state uninterruptible in >>any case. >> >> > >I do not think it would be safe to deliver a signal to a parent >process while a vforked child is borrowing its address space. > >Here's a patch against -STABLE: > >Index: kern_fork.c >=================================================================== >RCS file: /cvs/src/sys/kern/kern_fork.c,v >retrieving revision 1.72.2.15 >diff -u -r1.72.2.15 kern_fork.c >--- kern_fork.c 28 Sep 2003 11:08:31 -0000 1.72.2.15 >+++ kern_fork.c 4 Nov 2003 19:13:33 -0000 >@@ -130,6 +130,9 @@ > int error; > struct proc *p2; > >+ /* Don't allow kernel only flags. */ >+ if ((uap->flags & RFKERNELONLY) != 0) >+ return (EINVAL); > error = fork1(p, uap->flags, &p2); > if (error == 0) { > p->p_retval[0] = p2 ? p2->p_pid : 0; >_______________________________________________ >freebsd-hackers@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > I don't think -STABLE defines RFKERNELONLY (or some of the other rfork flags), so you need to add Index: unistd.h =================================================================== RCS file: /pub/FreeBSD/development/FreeBSD-CVS/src/sys/sys/unistd.h,v retrieving revision 1.22.2.2 diff -u -r1.22.2.2 unistd.h --- unistd.h 22 Aug 2000 01:46:30 -0000 1.22.2.2 +++ unistd.h 4 Nov 2003 19:46:03 -0000 @@ -218,6 +218,7 @@ #define RFSIGSHARE (1<<14) /* share signal handlers */ #define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */ #define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */ +#define RFKERNELONLY RFPPWAIT #endif /* !_POSIX_SOURCE */