]> sourceware.org Git - glibc.git/commit
hurd: Make sure to not use tcb->self
authorSergey Bugaev <bugaevc@gmail.com>
Wed, 17 May 2023 19:14:32 +0000 (22:14 +0300)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 17 May 2023 20:59:50 +0000 (22:59 +0200)
commitc7fcce38c83a2bb665ef5dc4981bf20c7e586123
tree5f8c474fc9c8af09835e720f74060b1b1b27d23b
parentaa19c68d2bdf3a831894f609b8ac5c8f123268b2
hurd: Make sure to not use tcb->self

Unlike sigstate->thread, tcb->self did not hold a Mach port reference on
the thread port it names. This means that the port can be deallocated,
and the name reused for something else, without anyone noticing. Using
tcb->self will then lead to port use-after-free.

Fortunately nothing was accessing tcb->self, other than it being
intially set to then-valid thread port name upon TCB initialization. To
assert that this keeps being the case without altering TCB layout,
rename self -> self_do_not_use, and stop initializing it.

Also, do not (re-)allocate a whole separate and unused stack for the
main thread, and just exit __pthread_setup early in this case.

Found upon attempting to use tcb->self and getting unexpected crashes.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230517191436.73636-7-bugaevc@gmail.com>
sysdeps/mach/hurd/i386/tls.h
sysdeps/mach/hurd/x86/htl/pt-setup.c
sysdeps/mach/hurd/x86_64/tls.h
This page took 0.043443 seconds and 5 git commands to generate.