lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 8 Dec 2016 05:44:10 -0800
From:   tip-bot for Oleg Nesterov <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     akpm@...ux-foundation.org, tj@...nel.org, oleg@...hat.com,
        alexander.deucher@....com, luto@...capital.net,
        roman.penyaev@...fitbricks.com, linux-kernel@...r.kernel.org,
        hpa@...or.com, tglx@...utronix.de, David1.Zhou@....com,
        pmladek@...e.com, luto@...nel.org, mingo@...nel.org,
        peterz@...radead.org
Subject: [tip:sched/core] kthread: Don't use to_live_kthread() in
 kthread_stop()

Commit-ID:  efb29fbfa50c490dac64a9418ebe553be82df781
Gitweb:     http://git.kernel.org/tip/efb29fbfa50c490dac64a9418ebe553be82df781
Author:     Oleg Nesterov <oleg@...hat.com>
AuthorDate: Tue, 29 Nov 2016 18:51:03 +0100
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Thu, 8 Dec 2016 14:36:19 +0100

kthread: Don't use to_live_kthread() in kthread_stop()

kthread_stop() had to use to_live_kthread() simply because it was not
possible to access kthread->exited after the exiting task clears
task_struct->vfork_done. Now that to_kthread() is always valid,
wake_up_process() + wait_for_completion() can be done
ununconditionally. It's not an issue anymore if the task has already issued
complete_vfork_done() or died.

The exiting task can get the spurious wakeup after mm_release() but this is
possible without this change too and is fine; do_task_dead() ensures that
this can't make any harm.

As a further enhancement this could be converted to task_work_add() later,
so ->vfork_done can be avoided completely.

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Chunming Zhou <David1.Zhou@....com>
Cc: Roman Pen <roman.penyaev@...fitbricks.com>
Cc: Petr Mladek <pmladek@...e.com>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Tejun Heo <tj@...nel.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Alex Deucher <alexander.deucher@....com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Link: http://lkml.kernel.org/r/20161129175103.GA5336@redhat.com
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>

---
 kernel/kthread.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 7891a94..4dcbc8b 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -532,13 +532,11 @@ int kthread_stop(struct task_struct *k)
 	trace_sched_kthread_stop(k);
 
 	get_task_struct(k);
-	kthread = to_live_kthread(k);
-	if (kthread) {
-		set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
-		__kthread_unpark(k, kthread);
-		wake_up_process(k);
-		wait_for_completion(&kthread->exited);
-	}
+	kthread = to_kthread(k);
+	set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
+	__kthread_unpark(k, kthread);
+	wake_up_process(k);
+	wait_for_completion(&kthread->exited);
 	ret = k->exit_code;
 	put_task_struct(k);
 

Powered by blists - more mailing lists