Setting t.tg.exiting during PrepareGroupExit prevents a SIGKILL that
arrives while the task is zombied from changing the exit status (see
ThreadGroup.applySignalSideEffectsLocked).
However, PrepareExit does not set t.tg.exiting, meaning that if the last
task exits via exit(2), then a SIGKILL _can_ change the exit status.
This does not match Linux.
Fix this by detecting that we are the last task in PrepareExit and, if
so, going through the PrepareGroupExit path.
My initial version of this CL had Task.exitThreadGroup set t.tg.exiting
if it wasn't already set. This leaves a small window between return from
exit(2) and the start of the runExit state where a SIGKILL could still
change the exit status. While this window likely doesn't matter much in
practice, I suspect it is observable via ptrace, which could see exit(2)
return and assume that the exit status is fixed. I didn't test this
case, but figured it would be cleaner to just close the race window.
Fixes#7930.
Based on the guidelines at
https://opensource.google.com/docs/releasing/authors/.
1. $ rg -l "Google LLC" | xargs sed -i 's/Google LLC.*/The gVisor Authors./'
2. Manual fixup of "Google Inc" references.
3. Add AUTHORS file. Authors may request to be added to this file.
4. Point netstack AUTHORS to gVisor AUTHORS. Drop CONTRIBUTORS.
Fixes#209
PiperOrigin-RevId: 245823212
Change-Id: I64530b24ad021a7d683137459cafc510f5ee1de9