Received: by 10.223.164.202 with SMTP id h10csp1181578wrb; Tue, 7 Nov 2017 23:35:38 -0800 (PST) X-Google-Smtp-Source: ABhQp+RflwTFxgEWu/Qo4bqWkNUnWqg7OTyugWw8TtNG43ik+poxgGJAvjY8MAzIhL04wY+dme1F X-Received: by 10.84.248.10 with SMTP id p10mr1375579pll.447.1510126538136; Tue, 07 Nov 2017 23:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510126538; cv=none; d=google.com; s=arc-20160816; b=X0oZWH57plNsu26Vvvn9v/YaB3yM/27fNm2jR1DgFdfasBsALAaV99PcUI15ujq1C/ 7/HLAGIr9Hk+Yt7YwFGUD2PuYox+QuWyjsHZBMg4LNvQgogARR5swYbH2qSXIgYMH+GY /LrvaPyT6FrQxTWO/7UILc/t8v1veygoVEWhlC1ai0FDhv1dzIfNQ/rSPWQhOtg1/tA7 MhvV8RS0u+hk/ibQywOg5kEed3v6xSeCQAlO7DB7e4m8IFaFjPxnEA6mmrinyb0MK0l7 C2DcrCHEqJ3tGN/ncxmwjahW+i8QvArRGm4Ys0YSB2NZTOkej1N9CfnFnPNQmILMKtYu F4EA== 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=k5SXRtMafU42ILaZceGKUrZoFspE21eZFCYz+z4sQOw=; b=iDg/s7+DLCs+P/0Iuub1ATNF1fPmrCb3qL/lI/bArCcOIpeut2BaoLbIy92SnG4TgQ ZPq9YchnxO4WPno/KCG3ZzuqlrOapx341tQloyJuAak449drMUXkG18jjz2HT+zFACIr //ZdQWjuqpbamuT6UkMrZRv+ffYCqKGbHVYN8A6cVVEfXMLshhO/adZHYEWKVeDLQgL1 kxASlznXuXuZYYg+nRxGjkeV50OjhL5gu1kef3TbgmUq/D21c0Wna14APXM9pEGouUUw cPta32K10EI5xyLOQp7gE8NHIAAmQys+2cxWToTx7Av8wvd6KVzh+w198ZotaYiex0NA IPqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=JGr1KjAB; 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 j7si3141905pgn.37.2017.11.07.23.35.16; Tue, 07 Nov 2017 23:35:38 -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=JGr1KjAB; 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 S1757242AbdKGTJz (ORCPT + 90 others); Tue, 7 Nov 2017 14:09:55 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:32916 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751408AbdKGTJx (ORCPT ); Tue, 7 Nov 2017 14:09:53 -0500 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA7J1NxE002388 for ; Tue, 7 Nov 2017 11:09:53 -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=k5SXRtMafU42ILaZceGKUrZoFspE21eZFCYz+z4sQOw=; b=JGr1KjABQpZeXuvcAKA0TOgEEysSnmcjsw3TAOpbxQO1IigNyGP3QBUS/MRIsYQJXf0z FUSDfkyPSFMZpGErx6y7dyyhZ35wOHHwna+utdoIqWOLyN6L2itYlvrhYWjCv0HEeqPT S+GhdI6UY/ZSHUqTksQNnQS1dZvEMZBBWWs= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2e3j0wg7e9-6 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Nov 2017 11:09:53 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB13.TheFacebook.com (192.168.16.23) with Microsoft SMTP Server id 14.3.361.1; Tue, 7 Nov 2017 11:09:51 -0800 Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id BB9C942403A5; Tue, 7 Nov 2017 11:09:50 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: LKML , Jens Axboe CC: Andrew Morton , Ingo Molnar , Tejun Heo , Dmitry Vyukov Smtp-Origin-Cluster: prn2c22 Subject: [PATCH V2] kthread: zero the kthread data structure Date: Tue, 7 Nov 2017 11:09:50 -0800 Message-ID: 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 early. Please see xchg() statement in kthread()), which confuses free_kthread_struct. Instead of moving the blkcg_css initialization early, we simply zero the whole 'self' data structure, which doesn't sound much overhead. Reported-by: syzbot Fixes: 05e3db95ebfc ("kthread: add a mechanism to store cgroup info") Cc: Andrew Morton Cc: Ingo Molnar Cc: Tejun Heo Cc: Dmitry Vyukov Signed-off-by: Shaohua Li --- kernel/kthread.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index f87cd8b4..8dbe245 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -204,7 +204,7 @@ static int kthread(void *_create) struct kthread *self; int ret; - self = kmalloc(sizeof(*self), GFP_KERNEL); + self = kzalloc(sizeof(*self), GFP_KERNEL); set_kthread_struct(self); /* If user was SIGKILLed, I release the structure. */ @@ -220,13 +220,9 @@ static int kthread(void *_create) do_exit(-ENOMEM); } - self->flags = 0; 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 1583463364453779917@xxx Wed Nov 08 02:32:21 +0000 2017 X-GM-THRID: 1583463356155294722 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread