Message ID | 20221021075728.1209184-1-lizetao1@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp529720wrr; Thu, 20 Oct 2022 23:55:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6D1ykxXV/WfkkvzYNKdA5ytvlDDflxKSRUlMqwZ7v1m6WEC2e1YqTTc1NJZHa+v+0jCqnF X-Received: by 2002:a05:6a00:150c:b0:563:9f05:bd68 with SMTP id q12-20020a056a00150c00b005639f05bd68mr17797661pfu.44.1666335316984; Thu, 20 Oct 2022 23:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666335316; cv=none; d=google.com; s=arc-20160816; b=yRXGb5kWhCNRWotemUsVOOfgzq9N+LehpHT7bBAWXOkb+6pz9zm3T6tV3h4p0fIw1I vws/rrHR74YESDMsMeM7C4ymwGwKDXirs+tzA+pCBDi+gqL2BGzJgAIOusqPLmfq4IjA m6Q2xroDVI+wSRWAlqmlLhCzFrq7BInEfneOO73+fSK+C6JW4ohppYTExPMR7V7wER3E fRontCpeGvEJ6NHbjH0WrGQhLU0ExKAQFE/Vm3fl5CXdDVXREMnljTQfxBG8UnRas1A6 ouZ/O1+yrW89EzRLzbNgTHVQGa7yy2UHo6Ctg573FNuAzD4i9n0iNpVbnJ5yycw6i76W h/Rg== 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 :message-id:date:subject:cc:to:from; bh=e864rHjkafskrftpzWlXIFuaHahQCzA3uaKmlO71oPM=; b=GryxYmUf9KMHbB0g8aQXRphnjCoFbFltDkI/8tFAdGqHVzxsANLswT0+vV0oCEzOlD 5kPCj0wtIXnAh8EBbzZydiR+3TI6NrlkKh6W+xnG+ZfioKQtM/LghcI2FG/aHjn/LM2n Rl7F+nqdPJzQDE2PSBbC4EQyclYelMljWMwewJ8HN44JSrvVhzP7hxceCkqCRrd56Toz Bg0+oNkaCmWfg4H5vhJNOBfFVZ3pEcJSSFhnPKElC7/U73Wa/1EwRO0iGV/gRwv7q96v LhUJ+mZbjwS48O+T8wZbYK1219ziwMLooB3l3MlCV1KpJXcGcJLSuuYMFCY8r22t8QOu ldtg== 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 z18-20020a170902ccd200b0016da027a727si25165652ple.116.2022.10.20.23.55.04; Thu, 20 Oct 2022 23:55:16 -0700 (PDT) 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 S230016AbiJUGyQ (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Fri, 21 Oct 2022 02:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbiJUGyO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 02:54:14 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DAD822E8F8 for <linux-kernel@vger.kernel.org>; Thu, 20 Oct 2022 23:54:13 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MtwDV50ZbzHty9; Fri, 21 Oct 2022 14:54:02 +0800 (CST) Received: from huawei.com (10.175.101.6) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 14:54:10 +0800 From: Li Zetao <lizetao1@huawei.com> To: <richard@nod.at>, <miquel.raynal@bootlin.com>, <vigneshr@ti.com>, <axboe@kernel.dk>, <chaitanya.kulkarni@wdc.com> CC: <lizetao1@huawei.com>, <hch@lst.de>, <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] ubi: block: KASAN null-ptr-deref in ubiblock_create() Date: Fri, 21 Oct 2022 15:57:28 +0800 Message-ID: <20221021075728.1209184-1-lizetao1@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500012.china.huawei.com (7.221.188.12) 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747279220949006991?= X-GMAIL-MSGID: =?utf-8?q?1747279220949006991?= |
Series |
ubi: block: KASAN null-ptr-deref in ubiblock_create()
|
|
Commit Message
Li Zetao
Oct. 21, 2022, 7:57 a.m. UTC
There is a null-ptr-deref when testing the ubiblock tools:
KASAN: null-ptr-deref in range [0x0000000000000040-0x0000000000000047]
CPU: 1 PID: 2299 Comm: ubiblock Not tainted
6.1.0-rc1-00002-gebb24af8c872-dirty #12
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS 1.14.0-1.fc33 04/01/2014
RIP: 0010:ubiblock_create.cold+0x175/0x1b5 [ubi]
...
Call Trace:
vol_cdev_ioctl+0x6ce/0x870 [ubi]
__x64_sys_ioctl+0x11d/0x170
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7fd9141230ab
when blk_mq_alloc_tag_set() returns an error, the dev->gd is
uninitialized, that causing null-ptr-deref fault.
Fix it by replacing the disk_to_dev(dev->gd) with NULL, that
will printk "(NULL device *): ..." message if blk_mq_alloc_tag_set()
returns an error.
Fixes: 77567b25ab9f ("ubi: use blk_mq_alloc_disk and blk_cleanup_disk")
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
drivers/mtd/ubi/block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 75eaecc8639f..9625dc2f45e2 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -408,7 +408,7 @@ int ubiblock_create(struct ubi_volume_info *vi) ret = blk_mq_alloc_tag_set(&dev->tag_set); if (ret) { - dev_err(disk_to_dev(dev->gd), "blk_mq_alloc_tag_set failed"); + dev_err(NULL, "blk_mq_alloc_tag_set failed"); goto out_free_dev; }