Received: by 10.223.164.202 with SMTP id h10csp946849wrb; Tue, 7 Nov 2017 18:13:02 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q0F9/43tSyxgMzvmOHEuRQ3K1NFQLL3UA9KHgucjdpb+rNyCc9+3fEBV6z2U6Md36Qjmgf X-Received: by 10.84.164.231 with SMTP id l36mr662092plg.179.1510107182793; Tue, 07 Nov 2017 18:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510107182; cv=none; d=google.com; s=arc-20160816; b=lMWOMaSX+jxNPpj1gkdAliCinNiVQCC2ctn51aE5xxYku/mF/a+pi0RjPCU58ytPn0 T5U19rKcB8lFWPosQZg6ZSEjkbr1s+f5Li/ooqFv3w86+IFGJ50035xsyoi0OI4ouhph 4jYz/1eRKmFvphj8yDs3t4Zv3NPNTFPqRuHI2O17B4iq2vIoDJyyOlcfpRB9EacYjMlP XM31kAlgQf+HT+1507Pvk5FLE1b9MuG3UUxhwwKLE/eY3E5LC0v/Ih09ZrqtlWCDIp/A XQDGRmpdUJ+Genn7Tkf6NLa9Xw6s74RuhSakL6WZ6AMR7LXH37S166FZSRnYYYr80E6x rqJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject :smtp-origin-cluster:cc:to:smtp-origin-hostname:from :smtp-origin-hostprefix:dkim-signature:arc-authentication-results; bh=C4BMfzxvEwnsOT+eW3glWR3TRHxYHEduUfqID8VLdAc=; b=UQnftemRB+z60DIl6gn+rdL0bXQcqyNU0kGy0kNLG1C+ec8VYyRNPcPJOhtjzSBwgq +7VLQB2pk2hApG4hJ+X3F/RxAR/dkGq1gCmw2rXwGEEipYpyHLBmmJKYPRqvE6nqlw82 FSnqfwETnVfPkeiGr+OJhUKcYGIgLjrIfR/RwGmHQSA4lJLxxz9lozZbSTqqF5XaOb4C XzhAZ3WEW5xBKEvAfoOBTifB7jilk/bFPA+jdL5/IWpeDLdUnPPi6mHQYm8/DcDAxsz/ EcRXyRzHcFzp+GFbKeAhIGbYhtTY03BvlxTVTpXUkjgb4viIUdHbz/kAVZgH54fDhP5T bwHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=RTXW3WT4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si2470452plz.262.2017.11.07.18.12.50; Tue, 07 Nov 2017 18:13:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=RTXW3WT4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754260AbdKGR5f (ORCPT + 91 others); Tue, 7 Nov 2017 12:57:35 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:38864 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139AbdKGR5e (ORCPT ); Tue, 7 Nov 2017 12:57:34 -0500 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA7HtSgN031437 for ; Tue, 7 Nov 2017 09:57:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=C4BMfzxvEwnsOT+eW3glWR3TRHxYHEduUfqID8VLdAc=; b=RTXW3WT4tjB/2V+GKQ6Ftfooajq5DbIAj8y9itFfYhA17JFiOobsQ4OUPPRacpzuBnTY EVMcS1SxJ6J/m22UK4xzBtxsXQubHAPF69Jy5ltFuBTB0xcywM01iY9hzYaZuBMm8GB8 kgw8Vo1DQtwO4PMA44mda5R6cLNM2UXO+yo= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2e3ecxs73j-6 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Nov 2017 09:57:34 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB07.TheFacebook.com (192.168.16.17) with Microsoft SMTP Server id 14.3.361.1; Tue, 7 Nov 2017 09:57:32 -0800 Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id A3286424030D; Tue, 7 Nov 2017 09:57:03 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: LKML , Jens Axboe CC: Dmitry Vyukov , Andrew Morton , Ingo Molnar , Tejun Heo Smtp-Origin-Cluster: prn2c22 Subject: [PATCH] kthread: move the cgroup info initialization early Date: Tue, 7 Nov 2017 09:57:03 -0800 Message-ID: <28c1d60a523362bdf7db7a96a6b1ab80c8689141.1510077329.git.shli@fb.com> X-Mailer: git-send-email 2.9.5 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-07_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 From 1583365753999446770@xxx Tue Nov 07 00:40:53 +0000 2017 X-GM-THRID: 1583365753999446770 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread