From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754393AbdKGSGD (ORCPT ); Tue, 7 Nov 2017 13:06:03 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:51105 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753624AbdKGSGB (ORCPT ); Tue, 7 Nov 2017 13:06:01 -0500 X-Google-Smtp-Source: ABhQp+QCtmiX8UNeJvw3czxQ61xhPNSkq1P5W1NLaZjbaB8nE0nhleS4GMh2gtqEFeCm4+HoGo2jTA== Date: Tue, 7 Nov 2017 10:05:58 -0800 From: Tejun Heo To: Shaohua Li Cc: LKML , Jens Axboe , Dmitry Vyukov , Andrew Morton , Ingo Molnar Subject: Re: [PATCH] kthread: move the cgroup info initialization early Message-ID: <20171107180558.GA4164960@devbig577.frc2.facebook.com> References: <28c1d60a523362bdf7db7a96a6b1ab80c8689141.1510077329.git.shli@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28c1d60a523362bdf7db7a96a6b1ab80c8689141.1510077329.git.shli@fb.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 07, 2017 at 09:57:03AM -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. > > Reported-by: syzbot > Fix: 05e3db9(kthread: add a mechanism to store cgroup info) > Cc: Andrew Morton > Cc: Ingo Molnar > Cc: Tejun Heo > Signed-off-by: Shaohua Li > --- > 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 That's not a big struct and I can't imagine that avoiding zeroing it matters in anyway. Can't we just use kzalloc() instead and drop the ugly ifdef? Thanks. -- tejun