]> git.hungrycats.org Git - linux/commit
nbd: Add the maximum limit of allocated index in nbd_dev_add
authorZhong Jinghua <zhongjinghua@huawei.com>
Mon, 5 Jun 2023 12:21:59 +0000 (20:21 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:21:54 +0000 (13:21 +0100)
commit638eaac374647d73858fa01820e3d6a49f4c3b8f
tree92dee3d31e65fc9a25009a49911d7c118acd1ce5
parent173e191012aa8760dfd9de6ebe6e535dff2ed18f
nbd: Add the maximum limit of allocated index in nbd_dev_add

[ Upstream commit f12bc113ce904777fd6ca003b473b427782b3dde ]

If the index allocated by idr_alloc greater than MINORMASK >> part_shift,
the device number will overflow, resulting in failure to create a block
device.

Fix it by imiting the size of the max allocation.

Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230605122159.2134384-1-zhongjinghua@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/nbd.c