]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
block: Fix the maximum minor value is blk_alloc_ext_minor()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 26 Mar 2022 14:50:46 +0000 (15:50 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:40:16 +0000 (14:40 +0200)
commitf4980e916f853310cfd1a152c532741b4ac11c86
treee154ff480e12ce937708c601debab9ec4cdf4318
parent5aa445d529e8449b46bbc3d99d310f0087980a36
block: Fix the maximum minor value is blk_alloc_ext_minor()

BugLink: https://bugs.launchpad.net/bugs/1969110
commit d1868328dec5ae2cf210111025fcbc71f78dd5ca upstream.

ida_alloc_range(..., min, max, ...) returns values from min to max,
inclusive.

So, NR_EXT_DEVT is a valid idx returned by blk_alloc_ext_minor().

This is an issue because in device_add_disk(), this value is used in:
   ddev->devt = MKDEV(disk->major, disk->first_minor);
and NR_EXT_DEVT is '(1 << MINORBITS)'.

So, should 'disk->first_minor' be NR_EXT_DEVT, it would overflow.

Fixes: 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/cc17199798312406b90834e433d2cefe8266823d.1648306232.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5b9ac3727e4abb11c9cfbe9c0781fc05dfdd7cfb)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
block/genhd.c