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-next>] [day] [month] [year] [list]
Date:   Mon, 25 Jun 2018 12:20:56 +0200
From:   Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
To:     linux-kernel@...r.kernel.org
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Oleg Nesterov <oleg@...hat.com>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Gavin Schenk <g.schenk@...elmann.de>, kernel@...gutronix.de
Subject: [PATCH] RFC: siox: don't create a thread without starting it

On a machine with a siox device I see:

	[  241.130465] INFO: task siox-0:626 blocked for more than 120 seconds.
	[  241.136996]       Not tainted 4.17.0-20180520-1-g6248d1b64190-dirty #8
	[  241.146831] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
	[  241.154868] siox-0          D    0   626      2 0x00000000
	[  241.163241] [<c05f8430>] (__schedule) from [<c05f88ec>] (schedule+0x58/0xc8)
	[  241.172142] [<c05f88ec>] (schedule) from [<c0039098>] (kthread+0xc4/0x140)
	[  241.180899] [<c0039098>] (kthread) from [<c00090e0>] (ret_from_fork+0x14/0x34)
	[  241.188315] Exception stack(0xc72a7fb0 to 0xc72a7ff8)
	[  241.196327] 7fa0:                                     00000000 00000000 00000000 00000000
	[  241.204721] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
	[  241.215861] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000

when I just boot without any other siox-related action. So the kthread (created
in drivers/siox/siox-core.c:siox_master_register()) is never started.

While you could argue that there is little reason to not start the
thread there also is little reason to actually do it.

peterz in #kernelnewbies said "[...] kernel/kthread.c:kthread() should
really be using __set_current_state(TASK_IDLE), I suppose". This however
seems to interfere with problems fixed in a076e4bca2fd ("freezer: fix
kthread_create vs freezer theoretical race").

So I wonder where the real problem is and how it can be fixed.

Explicitly-not-signed-off-for-discussion-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
---
 drivers/siox/siox-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index 16590dfaafa4..cef307c0399c 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -715,17 +715,17 @@ int siox_master_register(struct siox_master *smaster)
 
 	dev_set_name(&smaster->dev, "siox-%d", smaster->busno);
 
+	mutex_init(&smaster->lock);
+	INIT_LIST_HEAD(&smaster->devices);
+
 	smaster->last_poll = jiffies;
-	smaster->poll_thread = kthread_create(siox_poll_thread, smaster,
-					      "siox-%d", smaster->busno);
+	smaster->poll_thread = kthread_run(siox_poll_thread, smaster,
+					   "siox-%d", smaster->busno);
 	if (IS_ERR(smaster->poll_thread)) {
 		smaster->active = 0;
 		return PTR_ERR(smaster->poll_thread);
 	}
 
-	mutex_init(&smaster->lock);
-	INIT_LIST_HEAD(&smaster->devices);
-
 	ret = device_add(&smaster->dev);
 	if (ret)
 		kthread_stop(smaster->poll_thread);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ