mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
[hppa] Fix incorrect stack frame usage in vfork.
In a multithreaded environment the call to vfork was incorrectly creating a stack frame. Given that the child unwinds the stack frame first to call exec, it will corrupt any values the parent stored in the stack frame. The solution is to avoid creating a stack frame unless required to call an error function, in which case we are assured no child was created.
This commit is contained in:
parent
131fafa7da
commit
3680f14a7d
@ -1,3 +1,9 @@
|
|||||||
|
2010-06-24 Carlos O'Donell <carlos@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S: Only create stack
|
||||||
|
frame around call to SYSCALL_ERROR_HANDLER. Do not restore %rp
|
||||||
|
from the stack frame on successfull return.
|
||||||
|
|
||||||
2010-06-23 Carlos O'Donell <carlos@codesourcery.com>
|
2010-06-23 Carlos O'Donell <carlos@codesourcery.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext_ret):
|
* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext_ret):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
/* Copyright (C) 2005, 2010 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -50,10 +50,9 @@
|
|||||||
|
|
||||||
/* r26, r25, r24, r23 are free since vfork has no arguments */
|
/* r26, r25, r24, r23 are free since vfork has no arguments */
|
||||||
ENTRY(__vfork)
|
ENTRY(__vfork)
|
||||||
/* Prologue */
|
/* We must not create a frame. When the child unwinds to call
|
||||||
stwm %r3, 64(%sp)
|
exec it will clobber the same frame that the parent
|
||||||
stw %sp, -4(%sp)
|
needs to unwind. */
|
||||||
stw %r19, -32(%sp)
|
|
||||||
|
|
||||||
/* Save the PIC register. */
|
/* Save the PIC register. */
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
@ -75,12 +74,20 @@ ENTRY(__vfork)
|
|||||||
comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
|
comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
|
||||||
b,n .Lerror
|
b,n .Lerror
|
||||||
|
|
||||||
/* Return, no need to restore the PIC register. */
|
/* Return, and DO NOT restore rp. The child may have called
|
||||||
ldw -84(%sp), %rp
|
functions that updated the frame's rp. This works because
|
||||||
bv %r0(%rp)
|
the kernel ensures rp is preserved across the vfork
|
||||||
ldwm -64(%sp), %r3
|
syscall. */
|
||||||
|
bv,n %r0(%rp)
|
||||||
|
|
||||||
.Lerror:
|
.Lerror:
|
||||||
|
/* Now we need a stack to call a function. We are assured
|
||||||
|
that there is no child now, so it's safe to create
|
||||||
|
a frame. */
|
||||||
|
stw %rp, -20(%sp)
|
||||||
|
stwm %r3, 64(%sp)
|
||||||
|
stw %sp, -4(%sp)
|
||||||
|
|
||||||
sub %r0,%ret0,%r3
|
sub %r0,%ret0,%r3
|
||||||
SYSCALL_ERROR_HANDLER
|
SYSCALL_ERROR_HANDLER
|
||||||
/* Restore the PIC register (in delay slot) on error */
|
/* Restore the PIC register (in delay slot) on error */
|
||||||
|
Loading…
Reference in New Issue
Block a user