Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Apr 2001 05:38:20 +0900
From:      "Akinori MUSHA" <knu@iDaemons.org>
To:        hackers@FreeBSD.org
Subject:   kern/26705
Message-ID:  <86zod213k3.wl@archon.local.idaemons.org>
In-Reply-To: <200104191453.f3JErb999480@freefall.freebsd.org>
References:  <200104191453.f3JErb999480@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

Please review the following patch.

The previous fix against uthread_fork.c, pointed out by PR#25110,
fixed the P_ALTSTACK problem, but it was not quite correct.  The
originator of PR#26705 claims that the problem is rooted in a bug of
fork(2) regarding the alternate signal stack.  See those PR's and
follow the links in them for details.

I'm really happy with the patch and have seen no problem yet, so I'd
like to commit it unless someone finds any problem.


Regards,

Index: lib/libc_r/uthread/uthread_fork.c
===================================================================
RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_fork.c,v
retrieving revision 1.24
diff -u -r1.24 uthread_fork.c
--- lib/libc_r/uthread/uthread_fork.c	2001/04/18 12:40:30	1.24
+++ lib/libc_r/uthread/uthread_fork.c	2001/04/19 12:01:42
@@ -32,7 +32,6 @@
  * $FreeBSD: src/lib/libc_r/uthread/uthread_fork.c,v 1.24 2001/04/18 12:40:30 deischen Exp $
  */
 #include <errno.h>
-#include <signal.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -113,16 +112,7 @@
 		else if (_pq_init(&_readyq) != 0) {
 			/* Abort this application: */
 			PANIC("Cannot initialize priority ready queue.");
-		} else if ((_thread_sigstack.ss_sp == NULL) &&
-		    ((_thread_sigstack.ss_sp = malloc(SIGSTKSZ)) == NULL))
-			PANIC("Unable to allocate alternate signal stack");
-		else {
-			/* Install the alternate signal stack: */
-			_thread_sigstack.ss_size = SIGSTKSZ;
-			_thread_sigstack.ss_flags = 0;
-			if (__sys_sigaltstack(&_thread_sigstack, NULL) != 0)
-				PANIC("Unable to install alternate signal stack");
-
+		} else {
 			/*
 			 * Enter a loop to remove all threads other than
 			 * the running thread from the thread list:
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.110
diff -u -r1.110 kern_fork.c
--- sys/kern/kern_fork.c	2001/03/28 11:52:53	1.110
+++ sys/kern/kern_fork.c	2001/04/19 10:50:35
@@ -495,7 +495,7 @@
 	 * Preserve some more flags in subprocess.  PS_PROFIL has already
 	 * been preserved.
 	 */
-	p2->p_flag |= p1->p_flag & P_SUGID;
+	p2->p_flag |= p1->p_flag & (P_SUGID | P_ALTSTACK);
 	if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT)
 		p2->p_flag |= P_CONTROLT;
 	if (flags & RFPPWAIT)
Index: sys/kern/kern_sig.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.115
diff -u -r1.115 kern_sig.c
--- sys/kern/kern_sig.c	2001/04/12 02:38:07	1.115
+++ sys/kern/kern_sig.c	2001/04/19 10:50:35
@@ -464,6 +464,7 @@
 	p->p_sigstk.ss_flags = SS_DISABLE;
 	p->p_sigstk.ss_size = 0;
 	p->p_sigstk.ss_sp = 0;
+	p->p_flag &= ~P_ALTSTACK;
 	/*
 	 * Reset no zombies if child dies flag as Solaris does.
 	 */

-- 
                     /
                    /__  __            Akinori.org / MUSHA.org
                   / )  )  ) )  /     FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ /  ( (__(  @ iDaemons.org / and.or.jp

"Freeze this moment a little bit longer, make each impression
  a little bit stronger..  Experience slips away -- Time stand still"

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86zod213k3.wl>