* [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk()
@ 2023-12-19 7:59 linan666
2023-12-19 12:11 ` Christoph Hellwig
2023-12-19 15:23 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: linan666 @ 2023-12-19 7:59 UTC (permalink / raw)
To: axboe, penguin-kernel
Cc: linux-block, linux-kernel, linan666, yukuai3, yi.zhang, houtao1,
yangerkun
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(-)
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))
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk()
2023-12-19 7:59 [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk() linan666
@ 2023-12-19 12:11 ` Christoph Hellwig
2023-12-19 15:23 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-12-19 12:11 UTC (permalink / raw)
To: linan666
Cc: axboe, penguin-kernel, linux-block, linux-kernel, yukuai3,
yi.zhang, houtao1, yangerkun
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk()
2023-12-19 7:59 [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk() linan666
2023-12-19 12:11 ` Christoph Hellwig
@ 2023-12-19 15:23 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-12-19 15:23 UTC (permalink / raw)
To: penguin-kernel, linan666
Cc: linux-block, linux-kernel, yukuai3, yi.zhang, houtao1, yangerkun
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,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-19 15:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 7:59 [PATCH] block: add check of 'minors' and 'first_minor' in device_add_disk() linan666
2023-12-19 12:11 ` Christoph Hellwig
2023-12-19 15:23 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox