Subject: kern/1392: linux waitpid & wait4 fail if status == NULL
To: None <gnats-bugs@gnats.netbsd.org>
From: None <thomas@mathematik.uni-Bremen.de>
List: netbsd-bugs
Date: 08/21/1995 16:55:19
>Number: 1392
>Category: kern
>Synopsis: linux waitpid & wait4 fail if status == NULL
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Aug 21 11:05:02 1995
>Last-Modified:
>Originator: Thomas Eberhardt
>Organization:
CeVis, University of Bremen, Germany
>Release: NetBSD-current 950819
>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);
! }
}
/*
>Audit-Trail:
>Unformatted: