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:   Tue, 7 Nov 2017 09:57:03 -0800
From:   Shaohua Li <shli@...com>
To:     LKML <linux-kernel@...r.kernel.org>, Jens Axboe <axboe@...nel.dk>
CC:     Dmitry Vyukov <dvyukov@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>, Tejun Heo <tj@...nel.org>
Subject: [PATCH] kthread: move the cgroup info initialization early

kthread() could bail out early before we initialize blkcg_css (if the
kthread is killed very soon), which confuses free_kthread_struct. Move
the blkcg_css initialization early.

Reported-by: syzbot <syzkaller@...glegroups.com>
Fix: 05e3db9(kthread: add a mechanism to store cgroup info)
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Tejun Heo <tj@...nel.org>
Signed-off-by: Shaohua Li <shli@...com>
---
 kernel/kthread.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index f87cd8b4..cf5c113 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -205,6 +205,10 @@ static int kthread(void *_create)
 	int ret;
 
 	self = kmalloc(sizeof(*self), GFP_KERNEL);
+#ifdef CONFIG_BLK_CGROUP
+	if (self)
+		self->blkcg_css = NULL;
+#endif
 	set_kthread_struct(self);
 
 	/* If user was SIGKILLed, I release the structure. */
@@ -224,9 +228,6 @@ static int kthread(void *_create)
 	self->data = data;
 	init_completion(&self->exited);
 	init_completion(&self->parked);
-#ifdef CONFIG_BLK_CGROUP
-	self->blkcg_css = NULL;
-#endif
 	current->vfork_done = &self->exited;
 
 	/* OK, tell user we're spawned, wait for stop or wakeup */
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ