From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 20 07:40:03 2005 Return-Path: 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 9E47C16A4CE for ; Wed, 20 Apr 2005 07:40:03 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C6A443D45 for ; Wed, 20 Apr 2005 07:40:03 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3K7e3tB033093 for ; Wed, 20 Apr 2005 07:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j3K7e3Ds033091; Wed, 20 Apr 2005 07:40:03 GMT (envelope-from gnats) Resent-Date: Wed, 20 Apr 2005 07:40:03 GMT Resent-Message-Id: <200504200740.j3K7e3Ds033091@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kostik Belousov Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A90016A4CE for ; Wed, 20 Apr 2005 07:30:10 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5940443D39 for ; Wed, 20 Apr 2005 07:30:10 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j3K7U7Sx020056 for ; Wed, 20 Apr 2005 07:30:07 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j3K7U7OU020055; Wed, 20 Apr 2005 07:30:07 GMT (envelope-from nobody) Message-Id: <200504200730.j3K7U7OU020055@www.freebsd.org> Date: Wed, 20 Apr 2005 07:30:07 GMT From: Kostik Belousov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: kern/80130: [patch] sigprocmask erronously cleared on fork (5-STABLE and later) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2005 07:40:03 -0000 >Number: 80130 >Category: kern >Synopsis: [patch] sigprocmask erronously cleared on fork (5-STABLE and later) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 20 07:40:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Kostik Belousov >Release: 5-STABLE >Organization: >Environment: FreeBSD deviant.zoral.local 5.4-STABLE FreeBSD 5.4-STABLE #16: Tue Apr 12 11:06:01 EEST 2005 root@deviant.zoral.local:/usr/obj/usr/src/sys/DEVIANT i386 >Description: After fork(), the 5-STABLE system sets the child process blocked signal mask to 0 (let us account single-threaded processes only). I was under impression that signal mask shall be inherited by the child process (according to SUSv3 and man fork). Inheritance _was_ the behaviour of 4-STABLE (there, p_sigmask belongs to struct proc and placed in the copied-on-fork part of the structure) and also seen on other UNIXes (e.g. Solaris). It seems that needs of thread_schedule_upcall() to zero sigmask interfere with the needs of the fork1(). I propose the trivial patch (against 5-STABLE) to fix the problems. It handles td_sigmask in the way similar to td_sigstk, that is also zeroed on _upcall(), as was done by davidxu at kern/kern_fork.c:1.209 rev. >How-To-Repeat: I send the letter to the freebsd-hackers at Apr 12, 2005 with the program that shows the problem, see http://lists.freebsd.org/pipermail/freebsd-hackers/2005-April/011513.html >Fix: Index: kern/kern_fork.c =================================================================== RCS file: /usr/local/arch/ncvs/src/sys/kern/kern_fork.c,v retrieving revision 1.234.2.8 diff -U3 -r1.234.2.8 kern_fork.c --- kern/kern_fork.c 27 Feb 2005 02:36:39 -0000 1.234.2.8 +++ kern/kern_fork.c 20 Apr 2005 07:27:00 -0000 @@ -472,6 +472,7 @@ __rangeof(struct ksegrp, kg_startcopy, kg_endcopy)); td2->td_sigstk = td->td_sigstk; + td2->td_sigmask = td->td_sigmask; /* * Duplicate sub-structures as needed. >Release-Note: >Audit-Trail: >Unformatted: