From 250b33b964fcbef5cc5ffdcfbf97e0a856acbbe5 Mon Sep 17 00:00:00 2001 From: jkh Date: Thu, 10 Dec 1998 13:47:18 +0000 Subject: [PATCH] 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. PR: 9038 Submitted-By: Richard Seaman, Jr. --- sys/compat/linux/linux_misc.c | 15 ++++++++++++--- sys/i386/linux/linux_misc.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 35ce1bf071f8..68fee0f657d6 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.45 1998/10/05 12:40:42 sos Exp $ + * $Id: linux_misc.c,v 1.46 1998/12/04 22:54:50 archie Exp $ */ #include @@ -659,14 +659,23 @@ int 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 - if (error = pipe(p, 0)) + 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))) + } + + 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; } diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c index 35ce1bf071f8..68fee0f657d6 100644 --- a/sys/i386/linux/linux_misc.c +++ b/sys/i386/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.45 1998/10/05 12:40:42 sos Exp $ + * $Id: linux_misc.c,v 1.46 1998/12/04 22:54:50 archie Exp $ */ #include @@ -659,14 +659,23 @@ int 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 - if (error = pipe(p, 0)) + 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))) + } + + 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; }