OSDN Git Service

bionic: fix pthread_{create, exit}/signal race condition
authorJack Ren <jack.ren@intel.com>
Wed, 21 Sep 2011 10:44:11 +0000 (12:44 +0200)
committerJean-Baptiste Queru <jbq@google.com>
Wed, 30 Nov 2011 01:09:51 +0000 (17:09 -0800)
commite480fc83b2887388d469eb3bf58c86c610f5b082
treec595c2a61a1a4aa4d5049762a0130af7c0442437
parent31e72bc3289acdd85b0b745fbf64c5949ca33432
bionic: fix pthread_{create, exit}/signal race condition

(1) in pthread_create:
    If the one signal is received before esp is subtracted by 16 and
    __thread_entry( ) is called, the stack will be cleared by kernel
    when it tries to contruct the signal stack frame. That will cause
    that __thread_entry will get a wrong tls pointer from the stack
    which leads to the segment fault when trying to access tls content.

(2) in pthread_exit
    After pthread_exit called system call unmap(), its stack will be
    freed.  If one signal is received at that time, there is no stack
    available for it.

Fixed by subtracting the child's esp by 16 before the clone system
call and by blocking signal handling before pthread_exit is started.

Author: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
libc/arch-x86/bionic/clone.S
libc/bionic/pthread.c