Patch "nbd: Add the maximum limit of allocated index in nbd_dev_add" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nbd: Add the maximum limit of allocated index in nbd_dev_add

to the 5.4-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:
     nbd-add-the-maximum-limit-of-allocated-index-in-nbd_.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 456f7e7cba47667316050e9866ad8506c9e47f6f
Author: Zhong Jinghua <zhongjinghua@xxxxxxxxxx>
Date:   Mon Jun 5 20:21:59 2023 +0800

    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@xxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Link: https://lore.kernel.org/r/20230605122159.2134384-1-zhongjinghua@xxxxxxxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 218aa7e419700..37994a7a1b6f4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1708,7 +1708,8 @@ static int nbd_dev_add(int index)
 		if (err == -ENOSPC)
 			err = -EEXIST;
 	} else {
-		err = idr_alloc(&nbd_index_idr, nbd, 0, 0, GFP_KERNEL);
+		err = idr_alloc(&nbd_index_idr, nbd, 0,
+				(MINORMASK >> part_shift) + 1, GFP_KERNEL);
 		if (err >= 0)
 			index = err;
 	}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux