]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - kernel/kthread.c
userns: prevent speculative execution
[mirror_ubuntu-artful-kernel.git] / kernel / kthread.c
index 26db528c1d881bf371ea5b53b7ade0815c990bf1..e1285a91fc48541ebae64ad3fb55d07cf17f0433 100644 (file)
@@ -294,6 +294,17 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
         * new kernel thread.
         */
        if (unlikely(wait_for_completion_killable(&done))) {
+               int i = 0;
+
+               /*
+                * I got SIGKILL, but wait for 10 more seconds for completion
+                * unless chosen by the OOM killer. This delay is there as a
+                * workaround for boot failure caused by SIGKILL upon device
+                * driver initialization timeout.
+                */
+               while (i++ < 10 && !test_tsk_thread_flag(current, TIF_MEMDIE))
+                       if (wait_for_completion_timeout(&done, HZ))
+                               goto ready;
                /*
                 * If I was SIGKILLed before kthreadd (or new kernel thread)
                 * calls complete(), leave the cleanup of this structure to
@@ -307,6 +318,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
                 */
                wait_for_completion(&done);
        }
+ready:
        task = create->result;
        if (!IS_ERR(task)) {
                static const struct sched_param param = { .sched_priority = 0 };
@@ -637,6 +649,7 @@ repeat:
                schedule();
 
        try_to_freeze();
+       cond_resched();
        goto repeat;
 }
 EXPORT_SYMBOL_GPL(kthread_worker_fn);