From patchwork Mon Nov 28 15:44:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 26827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750388wrr; Mon, 28 Nov 2022 07:28:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6my/HQw0Sxa42jySsia6tQGNmc8xY1CHk+O4hQcaSMBkZKKEvVtpHi9Q30g/H+61BJnc7a X-Received: by 2002:a50:f602:0:b0:469:4e4f:4827 with SMTP id c2-20020a50f602000000b004694e4f4827mr40311396edn.214.1669649303787; Mon, 28 Nov 2022 07:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649303; cv=none; d=google.com; s=arc-20160816; b=o6iAcm8MY5Sp/k8RT69zo0n2rb0dSFv05OFH0oAIJbfZfUl5iKghEAyBeIHcQlnn3e pXHDqTc5WoO8VVQFKNBi85Lpc+cMjVxnfCpWURdJHWQJX8v7AWxTpXxN6gC5nf0X04Qa pTz/+BiYHt0onmQjCuW8ceFKoecwEYLjtLQZYTx3P2UYVc3yZm7wezLhrJGmdG7L6Aov kflamcqb5bgDqXRHel8Ps+/YoMGF6i6gYWjQs085SMEUeTncCJfnge/zE5eD2L/C2VPL DMS4lVdslxh4KZP5OP0lvvJpdbgOzK2SUuxoM1xTSpNvFEq8C6ysxRPg07pQiKrucAfa x1QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DFv0pknN1CNLR3dxTrIaXMFbPHMpYDqm9AJmGvSasDE=; b=P3xDeBXYWz3MZkp5HszbDI3w1xO1T7hYVzNDjH0mfR1zFoXbJ2NcesCZk1XRfc54am V5L8fyxb+HdBlqt9pnignKFk11NYy8wcEt+RJIyV390VEvViajEpUnIFDsYe278d+cWC rzM3MfVnSzvBaJSKazeDa5MLdO7N87wVfNenrnLhQXgQqzkhOG2ePmadw82bbxN5rK2s N9zas6ppzlNcrbAFVPjk+Twbw9slciu9PigQgKxIlR6WtBKID576ZRcpe49phD1QFPFD oZdEkVkt6KHeLVmAXaDjx1PmXlK4NFi//BjYFH2+IOQERxBWtEo+re0uNBI9XqReFCoC pCgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a1709065d0500b007ada2efa6b7si11520092ejt.567.2022.11.28.07.27.58; Mon, 28 Nov 2022 07:28:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231964AbiK1PYB (ORCPT + 99 others); Mon, 28 Nov 2022 10:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbiK1PXc (ORCPT ); Mon, 28 Nov 2022 10:23:32 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 617072DFC; Mon, 28 Nov 2022 07:23:32 -0800 (PST) Received: from dggpeml500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NLTk15F8fzHw8m; Mon, 28 Nov 2022 23:22:49 +0800 (CST) Received: from dggpeml500003.china.huawei.com (7.185.36.200) by dggpeml500020.china.huawei.com (7.185.36.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 28 Nov 2022 23:23:30 +0800 Received: from huawei.com (10.175.127.227) by dggpeml500003.china.huawei.com (7.185.36.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 28 Nov 2022 23:23:30 +0800 From: Li Nan To: , , CC: , , , , , Subject: [PATCH -next 8/8] block: fix null-pointer dereference in ioc_pd_init Date: Mon, 28 Nov 2022 23:44:34 +0800 Message-ID: <20221128154434.4177442-9-linan122@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221128154434.4177442-1-linan122@huawei.com> References: <20221128154434.4177442-1-linan122@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500003.china.huawei.com (7.185.36.200) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750754188451215720?= X-GMAIL-MSGID: =?utf-8?q?1750754188451215720?= Remove block device when iocost is initializing may cause null-pointer dereference: CPU1 CPU2 ioc_qos_write blkcg_conf_open_bdev blkdev_get_no_open kobject_get_unless_zero blk_iocost_init rq_qos_add del_gendisk rq_qos_exit q->rq_qos = rqos->next //iocost is removed from q->roqs blkcg_activate_policy pd_init_fn ioc_pd_init ioc = q_to_ioc(blkg->q) //cant find iocost and return null Fix problem by moving rq_qos_exit() to disk_release(). ioc_qos_write() get bd_device.kobj in blkcg_conf_open_bdev(), so disk_release will not be actived until iocost initialization is complited. Signed-off-by: Li Nan --- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index dcf200bcbd3e..c264da49eaaa 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -656,7 +656,6 @@ void del_gendisk(struct gendisk *disk) elevator_exit(q); mutex_unlock(&q->sysfs_lock); } - rq_qos_exit(q); blk_mq_unquiesce_queue(q); /* @@ -1168,6 +1167,7 @@ static void disk_release(struct device *dev) !test_bit(GD_ADDED, &disk->state)) blk_mq_exit_queue(disk->queue); + rq_qos_exit(q); blkcg_exit_disk(disk); bioset_exit(&disk->bio_split);