Skip to content

Commit 30b692d

Browse files
committed
exit: make setting exit_state consistent
Since commit b191d64 ("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 <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Cc: Linus Torvalds <[email protected]>
1 parent 1caf7d5 commit 30b692d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/exit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,10 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
734734
autoreap = true;
735735
}
736736

737-
tsk->exit_state = autoreap ? EXIT_DEAD : EXIT_ZOMBIE;
738-
if (tsk->exit_state == EXIT_DEAD)
737+
if (autoreap) {
738+
tsk->exit_state = EXIT_DEAD;
739739
list_add(&tsk->ptrace_entry, &dead);
740+
}
740741

741742
/* mt-exec, de_thread() is waiting for group leader */
742743
if (unlikely(tsk->signal->notify_count < 0))

0 commit comments

Comments
 (0)