]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - kernel/signal.c
threadgroup: extend threadgroup_lock() to cover exit and exec
[mirror_ubuntu-zesty-kernel.git] / kernel / signal.c
index d252be2d3de50e5c3f3a871cbd307bb7518aeac4..399c184bf0aee421eed5f81b123e9259d408f96e 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include <linux/slab.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
@@ -2359,8 +2359,15 @@ void exit_signals(struct task_struct *tsk)
        int group_stop = 0;
        sigset_t unblocked;
 
+       /*
+        * @tsk is about to have PF_EXITING set - lock out users which
+        * expect stable threadgroup.
+        */
+       threadgroup_change_begin(tsk);
+
        if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) {
                tsk->flags |= PF_EXITING;
+               threadgroup_change_end(tsk);
                return;
        }
 
@@ -2370,6 +2377,9 @@ void exit_signals(struct task_struct *tsk)
         * see wants_signal(), do_signal_stop().
         */
        tsk->flags |= PF_EXITING;
+
+       threadgroup_change_end(tsk);
+
        if (!signal_pending(tsk))
                goto out;