From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755486AbdKGSPi (ORCPT ); Tue, 7 Nov 2017 13:15:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755258AbdKGSPh (ORCPT ); Tue, 7 Nov 2017 13:15:37 -0500 Date: Tue, 7 Nov 2017 10:15:35 -0800 From: Andrew Morton To: Shaohua Li Cc: LKML , Jens Axboe , Dmitry Vyukov , Ingo Molnar , Tejun Heo Subject: Re: [PATCH] kthread: move the cgroup info initialization early Message-Id: <20171107101535.6d4c3e934d73a6d231af82d0@linux-foundation.org> In-Reply-To: <28c1d60a523362bdf7db7a96a6b1ab80c8689141.1510077329.git.shli@fb.com> References: <28c1d60a523362bdf7db7a96a6b1ab80c8689141.1510077329.git.shli@fb.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Nov 2017 09:57:03 -0800 Shaohua Li wrote: > 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. Changelog is... minimal. I guess it doesn't matter much. > Reported-by: syzbot > Fix: 05e3db9(kthread: add a mechanism to store cgroup info) That's a bit messed up. Please use Fixes: 05e3db95ebfc ("kthread: add a mechanism to store cgroup info") > --- 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 Using kzalloc() would be much neater. That way we get to delete a bit more code and it doesn't leave me wondering "under what circumstances is kthread.cpu uninitialized". At least, not as much as I am wondering right now.