This is a note to let you know that I've just added the patch titled Revert "Revert "block: nbd: add sanity check for first_minor"" to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: revert-revert-block-nbd-add-sanity-check-for-first_minor.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From wenyang.linux@xxxxxxxxxxx Thu Feb 23 10:40:14 2023 From: wenyang.linux@xxxxxxxxxxx Date: Tue, 21 Feb 2023 02:04:46 +0800 Subject: Revert "Revert "block: nbd: add sanity check for first_minor"" To: Sasha Levin <sashal@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Wen Yang <wenyang.linux@xxxxxxxxxxx>, Joel Stanley <joel@xxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Pavel Skripkin <paskripkin@xxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, stable@xxxxxxxxxxxxxxx Message-ID: <tencent_B38279CA0FF1F9A0CA887A2B886A92209D05@xxxxxx> From: Wen Yang <wenyang.linux@xxxxxxxxxxx> This reverts commit 0daa75bf750c400af0a0127fae37cd959d36dee7. These problems such as: https://lore.kernel.org/all/CACPK8XfUWoOHr-0RwRoYoskia4fbAbZ7DYf5wWBnv6qUnGq18w@xxxxxxxxxxxxxx/ It was introduced by introduced by commit b1a811633f73 ("block: nbd: add sanity check for first_minor") and has been have been fixed by commit e4c4871a7394 ("nbd: fix max value for 'first_minor'"). Cc: Joel Stanley <joel@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Pavel Skripkin <paskripkin@xxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Sasha Levin <sashal@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # v5.10+ Signed-off-by: Wen Yang <wenyang.linux@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/block/nbd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1771,7 +1771,17 @@ static int nbd_dev_add(int index) refcount_set(&nbd->refs, 1); INIT_LIST_HEAD(&nbd->list); disk->major = NBD_MAJOR; + + /* Too big first_minor can cause duplicate creation of + * sysfs files/links, since first_minor will be truncated to + * byte in __device_add_disk(). + */ disk->first_minor = index << part_shift; + if (disk->first_minor > 0xff) { + err = -EINVAL; + goto out_free_idr; + } + disk->fops = &nbd_fops; disk->private_data = nbd; sprintf(disk->disk_name, "nbd%d", index); Patches currently in stable-queue which might be from wenyang.linux@xxxxxxxxxxx are queue-5.10/revert-revert-block-nbd-add-sanity-check-for-first_minor.patch queue-5.10/nbd-fix-possible-overflow-on-first_minor-in-nbd_dev_add.patch queue-5.10/nbd-fix-possible-overflow-for-first_minor-in-nbd_dev_add.patch queue-5.10/nbd-fix-max-value-for-first_minor.patch