From dick@ns.tar.com  Thu Dec 10 05:10:44 1998
Received: from ns.tar.com (ns.tar.com [204.95.187.2])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA20016
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 10 Dec 1998 05:10:43 -0800 (PST)
          (envelope-from dick@ns.tar.com)
Received: (from dick@localhost)
	by ns.tar.com (8.9.1/8.9.1) id HAA08477;
	Thu, 10 Dec 1998 07:10:35 -0600 (CST)
	(envelope-from dick)
Message-Id: <199812101310.HAA08477@ns.tar.com>
Date: Thu, 10 Dec 1998 07:10:35 -0600 (CST)
From: dick@tar.com
Reply-To: dick@tar.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: <Synopsis of the problem (one line)>linux_pipe broken (patch included)
X-Send-Pr-Version: 3.2

>Number:         9038
>Category:       kern
>Synopsis:       linux_pipe broken (patch included)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 10 05:20:01 PST 1998
>Closed-Date:    Thu Dec 10 05:47:25 PST 1998
>Last-Modified:  Wed Oct 26 05:31:42 GMT 2005
>Originator:     Richard Seaman, Jr.
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	FreeBSD 3,0 current (may apply to 2.2.8, not sure)
	

>Description:

	linux_pipe does not preserve the edx register.  Linux and
	programs using glibc expect edx to be preserved accross syscalls.
	As a result, linux programs running in emulation mode can
	have whatever value may be represented by edx clobbered.

	In linux threads, this results in the process hanging (not sure
	why it doesn't seg fault since an address gets corrupted).
	In StarOffice 5.0 setup it results in a segfault.
	

>How-To-Repeat:

	Try executing StarOffice 5.0 setup.  Or, try running a program
	linked against linux threads (though you will need other patches
	to get this off the ground -- these will be submitted later
	after more testing).
	
	

>Fix:

Index: linux_misc.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/linux/linux_misc.c,v
retrieving revision 1.46
diff -c -r1.46 linux_misc.c
*** linux_misc.c	1998/12/04 22:54:50	1.46
--- linux_misc.c	1998/12/08 18:11:04
***************
*** 659,672 ****
  linux_pipe(struct proc *p, struct linux_pipe_args *args)
  {
      int error;
  
  #ifdef DEBUG
      printf("Linux-emul(%d): pipe(*)\n", p->p_pid);
  #endif
!     if (error = pipe(p, 0))
  	return error;
!     if (error = copyout(p->p_retval, args->pipefds, 2*sizeof(int)))
  	return error;
      p->p_retval[0] = 0;
      return 0;
  }
--- 659,681 ----
  linux_pipe(struct proc *p, struct linux_pipe_args *args)
  {
      int error;
+     int reg_edx;
  
  #ifdef DEBUG
      printf("Linux-emul(%d): pipe(*)\n", p->p_pid);
  #endif
!     reg_edx = p->p_retval[1];
!     if (error = pipe(p, 0)) {
!         p->p_retval[1] = reg_edx;
  	return error;
!     }
! 
!     if (error = copyout(p->p_retval, args->pipefds, 2*sizeof(int))) {
!         p->p_retval[1] = reg_edx;
  	return error;
+     }
+      
+     p->p_retval[1] = reg_edx;
      p->p_retval[0] = 0;
      return 0;
  }

	
	

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Thu Dec 10 05:47:25 PST 1998 
State-Changed-Why:  
Committed, thanks. 
>Unformatted:
