]> code.ossystems Code Review - openembedded-core.git/commit
glibc: Fix use after free in pthread_create()
authorYuanjie Huang <Yuanjie.Huang@windriver.com>
Wed, 29 Mar 2017 02:38:34 +0000 (19:38 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 18 May 2017 12:04:49 +0000 (13:04 +0100)
commiteaa844b6ce75d68f952de67ea5145a54a1968171
tree16ad64c1b105dcb7a37d1817b8b6af2cda592cff
parent1c6f6b014c2fca7bad93ce3b770721fd770bb006
glibc: Fix use after free in pthread_create()

[BZ 20116] -- https://sourceware.org/bugzilla/show_bug.cgi?id=20116

The commit documents the ownership rules around 'struct pthread' and
when a thread can read or write to the descriptor. With those ownership
rules in place it becomes obvious that pd->stopped_start should not be
touched in several of the paths during thread startup, particularly so
for detached threads. In the case of detached threads, between the time
the thread is created by the OS kernel and the creating thread checks
pd->stopped_start, the detached thread might have already exited and the
memory for pd unmapped. As a regression test we add a simple test which
exercises this exact case by quickly creating detached threads with
large enough stacks to ensure the thread stack cache is bypassed and the
stacks are unmapped. Before the fix the testcase segfaults, after the
fix it works correctly and completes without issue.

For a detailed discussion see:
https://www.sourceware.org/ml/libc-alpha/2017-01/msg00505.html

(cherry-picked from commit f8bf15febcaf137bbec5a61101e88cd5a9d56ca8)

Signed-off-by: Yuanjie Huang <yuanjie.huang@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/recipes-core/glibc/glibc/0028-Bug-20116-Fix-use-after-free-in-pthread_create.patch [new file with mode: 0644]
meta/recipes-core/glibc/glibc_2.24.bb