Message ID | 20231219075942.840255-1-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1781057dyi; Tue, 19 Dec 2023 00:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEK7VBkICMrzCB8vl73bjkFXKTithVNYqz+bbSqNnz0fgke2fuPH6Z0qucowogu19FNRifb X-Received: by 2002:a17:902:ecce:b0:1d0:8f0d:b6e4 with SMTP id a14-20020a170902ecce00b001d08f0db6e4mr9110136plh.111.1702972975105; Tue, 19 Dec 2023 00:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702972975; cv=none; d=google.com; s=arc-20160816; b=q5Sh9AfiYuCdLsjDftOq2x33Gz7zcB0XF6enG4eLadEJMpGIZpXprMDabqerx6DMpv fcvDXRJ0LmOr3qfuW926fUP+OLLiv2RtSb5hPXBCWOtDqEVK6OM/jCL6lmLHQyas6er+ lbrxudr5kvQoovDv3TY+AYHpacyGS+1OP1C8U1yk6yqNAJpA3qNp/yxSY+SGO4erfMCR hm6BzG5zlkKKvjNsAymbS+OeDMomL0W4bSq+ppoDuUQA8UNsCW5zbahC1Uhpo4fbSNko 8A7FneViRM7/b6KVVZlBXQUQZ19HWVIARCp7scGwxLE7zxGaKUVUHDBlDxU4ywMcKVIL Uajg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=fjFDnHZlxK0h/cWCUNQqYjFeCqkLG1SJbfrtoNXDR28=; fh=v3PS3pvUCvWXLF7JYheQZA61W3oEoZrX96q7+5i0mzQ=; b=U5bqnnjc5EJ6Mb69bdGSDIWWYm1PXSgAo82jrGOfmkcN0GAGc6w8WO0M0giIg31u3w UhDhCpIH4OqgbCMgdgo2FCEGJMqFM3D0udR4k8rqjShjXxMeU3k++lpCu9fO0nOI+ES0 OGMLfJ6aV4GpCqDxDtsZorBDq4DwiXh7ewRZ8v0NGVKhXBMnz6e9JjrOyu49A+8Hg/6B 5gseOBDhCUOAE6RXICPr3F847qqODXGAUpuNjRIMn7FyIXEZL0LjKFFHwiKBnfcfTq2g eGpASRo4xETNxHcmTnsp97sNY5VwW2XHPjoI3n/ntBdeM9N7lISY+i90wBjvsTRDvrMP QJ2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l7-20020a170903244700b001d352ecfa69si1453670pls.218.2023.12.19.00.02.54 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4857-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DD619283008 for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 08:02:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 476FF14293; Tue, 19 Dec 2023 08:01:42 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28B6612B92; Tue, 19 Dec 2023 08:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SvTfd1Dlkz4f3jLn; Tue, 19 Dec 2023 16:01:29 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 574DF1A01F5; Tue, 19 Dec 2023 16:01:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xHcTYFlh7s5EA--.45839S4; Tue, 19 Dec 2023 16:01:34 +0800 (CST) From: linan666@huaweicloud.com To: axboe@kernel.dk, penguin-kernel@i-love.sakura.ne.jp Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linan666@huaweicloud.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk() Date: Tue, 19 Dec 2023 15:59:42 +0800 Message-Id: <20231219075942.840255-1-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.k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r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnU UI43ZEXa7VUbSApUUUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785696589924120096 X-GMAIL-MSGID: 1785696589924120096 |
Series |
block: add check of 'minors' and 'first_minor' in device_add_disk()
|
|
Commit Message
Li Nan
Dec. 19, 2023, 7:59 a.m. UTC
From: Li Nan <linan122@huawei.com> 'first_minor' represents the starting minor number of disks, and 'minors' represents the number of partitions in the device. Neither of them can be greater than MINORMASK + 1. Commit e338924bd05d ("block: check minor range in device_add_disk()") only added the check of 'first_minor + minors'. However, their sum might be less than MINORMASK but their values are wrong. Complete the checks now. Fixes: e338924bd05d ("block: check minor range in device_add_disk()") Signed-off-by: Li Nan <linan122@huawei.com> --- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Comments
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Tue, 19 Dec 2023 15:59:42 +0800, linan666@huaweicloud.com wrote: > 'first_minor' represents the starting minor number of disks, and > 'minors' represents the number of partitions in the device. Neither > of them can be greater than MINORMASK + 1. > > Commit e338924bd05d ("block: check minor range in device_add_disk()") > only added the check of 'first_minor + minors'. However, their sum might > be less than MINORMASK but their values are wrong. Complete the checks now. > > [...] Applied, thanks! [1/1] block: add check of 'minors' and 'first_minor' in device_add_disk() commit: 4c434392c4777881d01beada6701eff8c76b43fe Best regards,
diff --git a/block/genhd.c b/block/genhd.c index c9d06f72c587..551b5693ebd5 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -432,7 +432,9 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, DISK_MAX_PARTS); disk->minors = DISK_MAX_PARTS; } - if (disk->first_minor + disk->minors > MINORMASK + 1) + if (disk->first_minor > MINORMASK || + disk->minors > MINORMASK + 1 || + disk->first_minor + disk->minors > MINORMASK + 1) goto out_exit_elevator; } else { if (WARN_ON(disk->minors))