android_kernel_google_msm/kernel
Oleg Nesterov d66d207818 wait: fix reparent_leader() vs EXIT_DEAD->EXIT_ZOMBIE race
commit dfccbb5e49 upstream.

wait_task_zombie() first does EXIT_ZOMBIE->EXIT_DEAD transition and
drops tasklist_lock.  If this task is not the natural child and it is
traced, we change its state back to EXIT_ZOMBIE for ->real_parent.

The last transition is racy, this is even documented in 50b8d25748
"ptrace: partially fix the do_wait(WEXITED) vs EXIT_DEAD->EXIT_ZOMBIE
race".  wait_consider_task() tries to detect this transition and clear
->notask_error but we can't rely on ptrace_reparented(), debugger can
exit and do ptrace_unlink() before its sub-thread sets EXIT_ZOMBIE.

And there is another problem which were missed before: this transition
can also race with reparent_leader() which doesn't reset >exit_signal if
EXIT_DEAD, assuming that this task must be reaped by someone else.  So
the tracee can be re-parented with ->exit_signal != SIGCHLD, and if
/sbin/init doesn't use __WALL it becomes unreapable.

Change reparent_leader() to update ->exit_signal even if EXIT_DEAD.
Note: this is the simple temporary hack for -stable, it doesn't try to
solve all problems, it will be reverted by the next changes.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Reported-by: Michal Schmidt <mschmidt@redhat.com>
Tested-by: Michal Schmidt <mschmidt@redhat.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Lennart Poettering <lpoetter@redhat.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-04-26 17:13:20 -07:00
..
debug
events perf: Fix hotplug splat 2014-03-11 16:10:02 -07:00
gcov
irq genirq: Remove racy waitqueue_active check 2014-03-23 21:37:05 -07:00
power PM / Hibernate: Hibernate/thaw fixes/improvements 2014-02-20 10:45:33 -08:00
sched sched: Fix double normalization of vruntime 2014-03-23 21:37:03 -07:00
time time: Fix overflow when HZ is smaller than 60 2014-02-22 10:32:46 -08:00
trace tracing: Do not add event files for modules that fail tracepoints 2014-03-23 21:37:06 -07:00
.gitignore
acct.c
async.c
audit.c audit: wait_for_auditd() should use TASK_UNINTERRUPTIBLE 2014-04-14 06:44:15 -07:00
audit.h
audit_tree.c kernel/audit_tree.c: tree will leak memory when failure occurs in audit_trim_trees() 2013-05-11 13:48:14 -07:00
audit_watch.c
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
cgroup.c cgroup: cgroup_subsys->fork() should be called after the task is added to css_set 2014-03-11 16:10:03 -07:00
cgroup_freezer.c cgroup: cgroup_subsys->fork() should be called after the task is added to css_set 2014-03-11 16:10:03 -07:00
compat.c
configs.c
cpu.c CPU hotplug: provide a generic helper to disable/enable CPU hotplug 2013-06-20 11:58:44 -07:00
cpu_pm.c
cpuset.c cpuset: fix a race condition in __cpuset_node_allowed_softwall() 2014-03-23 21:37:05 -07:00
crash_dump.c
cred.c
delayacct.c
dma.c
elfcore.c
exec_domain.c
exit.c wait: fix reparent_leader() vs EXIT_DEAD->EXIT_ZOMBIE race 2014-04-26 17:13:20 -07:00
extable.c
fork.c cgroup: cgroup_subsys->fork() should be called after the task is added to css_set 2014-03-11 16:10:03 -07:00
freezer.c
futex.c futex: fix handling of read-only-mapped hugepages 2013-12-20 07:34:19 -08:00
futex_compat.c
groups.c
hrtimer.c hrtimers: Move SMP function call to thread context 2013-07-28 16:26:47 -07:00
hung_task.c
irq_work.c
itimer.c
jump_label.c
kallsyms.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kexec.c
kfifo.c
kmod.c usermodehelper: check subprocess_info->path != NULL 2013-05-19 10:54:50 -07:00
kprobes.c
ksysfs.c
kthread.c
latencytop.c
lockdep.c
lockdep_internals.h
lockdep_proc.c
lockdep_states.h
Makefile
module.c
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid.c
pid_namespace.c
posix-cpu-timers.c
posix-timers.c
printk.c printk: Fix rq->lock vs logbuf_lock unlock lock inversion 2014-04-14 06:44:16 -07:00
profile.c
ptrace.c exec/ptrace: fix get_dumpable() incorrect tests 2013-11-29 10:50:34 -08:00
range.c
rcu.h
rcupdate.c
rcutiny.c
rcutiny_plugin.h
rcutorture.c
rcutree.c
rcutree.h
rcutree_plugin.h
rcutree_trace.c
relay.c
res_counter.c
resource.c
rtmutex-debug.c
rtmutex-debug.h
rtmutex-tester.c
rtmutex.c
rtmutex.h
rtmutex_common.h
rwsem.c
seccomp.c
semaphore.c
signal.c kernel/signal.c: stop info leak via the tkill and the tgkill syscalls 2013-04-25 21:19:54 -07:00
smp.c
softirq.c
spinlock.c
srcu.c
stacktrace.c
stop_machine.c
sys.c reboot: rigrate shutdown/reboot to boot cpu 2013-06-20 11:58:45 -07:00
sys_ni.c
sysctl.c
sysctl_binary.c
taskstats.c
test_kprobes.c
time.c
timeconst.pl
timer.c timer: Fix jiffies wrap behavior of round_jiffies_common() 2013-07-21 18:19:01 -07:00
tracepoint.c tracing: Do not add event files for modules that fail tracepoints 2014-03-23 21:37:06 -07:00
tsacct.c
uid16.c
up.c
user-return-notifier.c
user.c
user_namespace.c
utsname.c
utsname_sysctl.c
wait.c
watchdog.c
workqueue.c workqueue: cond_resched() after processing each work item 2014-04-14 06:44:16 -07:00
workqueue_sched.h