NetBSD Problem Report #1392

From gnats  Mon Aug 21 10:52:55 1995
Received: from forte.mathematik.uni-Bremen.de (thomas@forte.mathematik.uni-bremen.de [134.102.232.1]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id KAA17329 for <gnats-bugs@gnats.netbsd.org>; Mon, 21 Aug 1995 10:52:51 -0400
Message-Id: <199508211455.QAA28139@forte.mathematik.uni-Bremen.de>
Date: Mon, 21 Aug 1995 16:55:19 +0200
From: thomas@mathematik.uni-Bremen.de
Reply-To: thomas@mathematik.uni-Bremen.de
To: gnats-bugs@gnats.netbsd.org
Subject: linux waitpid & wait4 fail if status == NULL
X-Send-Pr-Version: 3.2

>Number:         1392
>Category:       kern
>Synopsis:       linux waitpid & wait4 fail if status == NULL
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 21 11:05:02 +0000 1995
>Closed-Date:    Mon Aug 21 23:39:16 +0000 1995
>Last-Modified:  Mon Aug 21 23:39:42 +0000 1995
>Originator:     Thomas Eberhardt
>Release:        NetBSD-current 950819
>Organization:
CeVis, University of Bremen, Germany
>Environment:

System: NetBSD ed209 1.0A NetBSD 1.0A (ED209) #4: Mon Aug 21 16:10:21 MET DST 1995     thomas@ed209:/usr/src/sys/arch/i386/compile/ED209 i386

Machine: i386
>Description:
	The linux compat code for waitpid & wait4 fails if the status
	argument is a NULL pointer.
>How-To-Repeat:
	Call the linux ldd binary (version 1.7.3 in my case) with a
	dynamically linked linux binary as an argument and watch it hang.
>Fix:
*** sys/compat/linux/linux_misc.c-	Mon Aug 21 09:00:14 1995
--- sys/compat/linux/linux_misc.c	Mon Aug 21 16:00:41 1995
***************
*** 112,134 ****
  	int error, *status, tstat;
  	caddr_t sg;

! 	sg = stackgap_init(p->p_emul);
! 	status = (int *) stackgap_alloc(&sg, sizeof status);

! 	SCARG(&w4a, pid) = SCARG(uap, pid);
! 	SCARG(&w4a, status) = status;
! 	SCARG(&w4a, options) = SCARG(uap, options);
! 	SCARG(&w4a, rusage) = NULL;
! 
! 	if ((error = wait4(p, &w4a, retval)))
! 		return error;
! 
! 	if ((error = copyin(status, &tstat, sizeof tstat)))
! 		return error;
! 
! 	bsd_to_linux_wstat(&tstat);
! 
! 	return copyout(&tstat, SCARG(uap, status), sizeof tstat);
  }

  /*
--- 112,143 ----
  	int error, *status, tstat;
  	caddr_t sg;

! 	if (SCARG(uap, status) != NULL) {
! 		sg = stackgap_init(p->p_emul);
! 		status = (int *) stackgap_alloc(&sg, sizeof status);
! 
! 		SCARG(&w4a, pid) = SCARG(uap, pid);
! 		SCARG(&w4a, status) = status;
! 		SCARG(&w4a, options) = SCARG(uap, options);
! 		SCARG(&w4a, rusage) = NULL;
! 
! 		if ((error = wait4(p, &w4a, retval)))
! 			return error;
! 
! 		if ((error = copyin(status, &tstat, sizeof tstat)))
! 			return error;
! 
! 		bsd_to_linux_wstat(&tstat);
! 
! 		return copyout(&tstat, SCARG(uap, status), sizeof tstat);
! 	} else {
! 		SCARG(&w4a, pid) = SCARG(uap, pid);
! 		SCARG(&w4a, status) = NULL;
! 		SCARG(&w4a, options) = SCARG(uap, options);
! 		SCARG(&w4a, rusage) = NULL;

! 		return wait4(p, &w4a, retval);
! 	}
  }

  /*
***************
*** 149,171 ****
  	int error, *status, tstat;
  	caddr_t sg;

! 	sg = stackgap_init(p->p_emul);
! 	status = (int *) stackgap_alloc(&sg, sizeof status);
! 
! 	SCARG(&w4a, pid) = SCARG(uap, pid);
! 	SCARG(&w4a, status) = status;
! 	SCARG(&w4a, options) = SCARG(uap, options);
! 	SCARG(&w4a, rusage) = SCARG(uap, rusage);
! 
! 	if ((error = wait4(p, &w4a, retval)))
! 		return error;
! 
! 	if ((error = copyin(status, &tstat, sizeof tstat)))
! 		return error;
! 
! 	bsd_to_linux_wstat(&tstat);

! 	return copyout(&tstat, SCARG(uap, status), sizeof tstat);
  }

  /*
--- 158,189 ----
  	int error, *status, tstat;
  	caddr_t sg;

! 	if (SCARG(uap, status) != NULL) {
! 		sg = stackgap_init(p->p_emul);
! 		status = (int *) stackgap_alloc(&sg, sizeof status);
! 
! 		SCARG(&w4a, pid) = SCARG(uap, pid);
! 		SCARG(&w4a, status) = status;
! 		SCARG(&w4a, options) = SCARG(uap, options);
! 		SCARG(&w4a, rusage) = SCARG(uap, rusage);
! 
! 		if ((error = wait4(p, &w4a, retval)))
! 			return error;
! 
! 		if ((error = copyin(status, &tstat, sizeof tstat)))
! 			return error;
! 
! 		bsd_to_linux_wstat(&tstat);
! 
! 		return copyout(&tstat, SCARG(uap, status), sizeof tstat);
! 	} else {
! 		SCARG(&w4a, pid) = SCARG(uap, pid);
! 		SCARG(&w4a, status) = NULL;
! 		SCARG(&w4a, options) = SCARG(uap, options);
! 		SCARG(&w4a, rusage) = NULL;

! 		return wait4(p, &w4a, retval);
! 	}
  }

  /*
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: fvdl 
State-Changed-When: Mon Aug 21 19:39:16 EDT 1995 
State-Changed-Why:  
Should be fixed now, thanks 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.