diff options
author | Christian Brauner <christian@brauner.io> | 2019-07-29 11:48:24 -0400 |
---|---|---|
committer | Christian Brauner <christian@brauner.io> | 2019-07-30 13:57:14 -0400 |
commit | 30b692d3b390c6fe78a5064be0c4bbd44a41be59 (patch) | |
tree | e50f2c2635beacd11be8b3e8d0c305781425ab27 | |
parent | 1caf7d50f46bd0388e38e653b146aa81700e8eb8 (diff) |
exit: make setting exit_state consistent
Since commit b191d6491be6 ("pidfd: fix a poll race when setting exit_state")
we unconditionally set exit_state to EXIT_ZOMBIE before calling into
do_notify_parent(). This was done to eliminate a race when querying
exit_state in do_notify_pidfd().
Back then we decided to do the absolute minimal thing to fix this and
not touch the rest of the exit_notify() function where exit_state is
set.
Since this fix has not caused any issues change the setting of
exit_state to EXIT_DEAD in the autoreap case to account for the fact hat
exit_state is set to EXIT_ZOMBIE unconditionally. This fix was planned
but also explicitly requested in [1] and makes the whole code more
consistent.
/* References */
[1]: https://lore.kernel.org/lkml/CAHk-=wigcxGFR2szue4wavJtH5cYTTeNES=toUBVGsmX0rzX+g@mail.gmail.com
Signed-off-by: Christian Brauner <christian@brauner.io>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/exit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 4436158a6d30..5b4a5dcce8f8 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -734,9 +734,10 @@ static void exit_notify(struct task_struct *tsk, int group_dead) | |||
734 | autoreap = true; | 734 | autoreap = true; |
735 | } | 735 | } |
736 | 736 | ||
737 | tsk->exit_state = autoreap ? EXIT_DEAD : EXIT_ZOMBIE; | 737 | if (autoreap) { |
738 | if (tsk->exit_state == EXIT_DEAD) | 738 | tsk->exit_state = EXIT_DEAD; |
739 | list_add(&tsk->ptrace_entry, &dead); | 739 | list_add(&tsk->ptrace_entry, &dead); |
740 | } | ||
740 | 741 | ||
741 | /* mt-exec, de_thread() is waiting for group leader */ | 742 | /* mt-exec, de_thread() is waiting for group leader */ |
742 | if (unlikely(tsk->signal->notify_count < 0)) | 743 | if (unlikely(tsk->signal->notify_count < 0)) |