|
@@ -1287,9 +1287,15 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
|
|
static int wait_consider_task(struct wait_opts *wo, int ptrace,
|
|
static int wait_consider_task(struct wait_opts *wo, int ptrace,
|
|
struct task_struct *p)
|
|
struct task_struct *p)
|
|
{
|
|
{
|
|
|
|
+ /*
|
|
|
|
+ * We can race with wait_task_zombie() from another thread.
|
|
|
|
+ * Ensure that EXIT_ZOMBIE -> EXIT_DEAD/EXIT_TRACE transition
|
|
|
|
+ * can't confuse the checks below.
|
|
|
|
+ */
|
|
|
|
+ int exit_state = ACCESS_ONCE(p->exit_state);
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
- if (unlikely(p->exit_state == EXIT_DEAD))
|
|
|
|
|
|
+ if (unlikely(exit_state == EXIT_DEAD))
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
ret = eligible_child(wo, p);
|
|
ret = eligible_child(wo, p);
|
|
@@ -1310,7 +1316,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
- if (unlikely(p->exit_state == EXIT_TRACE)) {
|
|
|
|
|
|
+ if (unlikely(exit_state == EXIT_TRACE)) {
|
|
/*
|
|
/*
|
|
* ptrace == 0 means we are the natural parent. In this case
|
|
* ptrace == 0 means we are the natural parent. In this case
|
|
* we should clear notask_error, debugger will notify us.
|
|
* we should clear notask_error, debugger will notify us.
|
|
@@ -1337,7 +1343,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
|
|
}
|
|
}
|
|
|
|
|
|
/* slay zombie? */
|
|
/* slay zombie? */
|
|
- if (p->exit_state == EXIT_ZOMBIE) {
|
|
|
|
|
|
+ if (exit_state == EXIT_ZOMBIE) {
|
|
/* we don't reap group leaders with subthreads */
|
|
/* we don't reap group leaders with subthreads */
|
|
if (!delay_group_leader(p)) {
|
|
if (!delay_group_leader(p)) {
|
|
/*
|
|
/*
|