]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nbd: fix possible overflow for 'first_minor' in nbd_dev_add()
authorYu Kuai <yukuai3@huawei.com>
Tue, 2 Nov 2021 01:52:35 +0000 (09:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:55:04 +0000 (11:55 +0100)
commit2e0c3e43ebb99c2b495229f8fade4c043fbd06a5
tree4275b967ce1940ea5e3c6d2609e042560d8a2c4c
parentfd8107206a672f5a529a819e8930bf81fb54ae0f
nbd: fix possible overflow for 'first_minor' in nbd_dev_add()

commit 940c264984fd1457918393c49674f6b39ee16506 upstream.

If 'part_shift' is not zero, then 'index << part_shift' might
overflow to a value that is not greater than '0xfffff', then sysfs
might complains about duplicate creation.

Fixes: b0d9111a2d53 ("nbd: use an idr to keep track of nbd devices")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20211102015237.2309763-3-yebin10@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/nbd.c