Sergey Bugaev c7fcce38c8 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>
2023-05-17 22:59:50 +02:00
..
2023-03-02 16:41:43 -03:00
2023-03-30 10:50:50 -03:00
2023-01-24 11:21:38 -05:00
2023-05-17 22:59:50 +02:00
2023-05-01 13:36:14 +02:00
2023-05-10 13:15:13 -04:00
2023-02-06 16:19:35 -03:00
2023-05-01 13:01:30 +02:00
2023-05-03 12:09:49 +01:00