Patch "null_blk: fix validation of block size" has been added to the 6.9-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

    null_blk: fix validation of block size

to the 6.9-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:
     null_blk-fix-validation-of-block-size.patch
and it can be found in the queue-6.9 subdirectory.

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



commit 781cbd1726a43a950c4f0c863fafb8b124a3499b
Author: Andreas Hindborg <a.hindborg@xxxxxxxxxxx>
Date:   Mon Jun 3 21:26:45 2024 +0200

    null_blk: fix validation of block size
    
    [ Upstream commit c462ecd659b5fce731f1d592285832fd6ad54053 ]
    
    Block size should be between 512 and PAGE_SIZE and be a power of 2. The current
    check does not validate this, so update the check.
    
    Without this patch, null_blk would Oops due to a null pointer deref when
    loaded with bs=1536 [1].
    
    Link: https://lore.kernel.org/all/87wmn8mocd.fsf@xxxxxxxxxxxx/
    
    Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxxx>
    Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240603192645.977968-1-nmi@xxxxxxxxxxxx
    [axboe: remove unnecessary braces and != 0 check]
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 620679a0ac381..26e2c22a87e1c 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1810,8 +1810,8 @@ static int null_validate_conf(struct nullb_device *dev)
 		dev->queue_mode = NULL_Q_MQ;
 	}
 
-	dev->blocksize = round_down(dev->blocksize, 512);
-	dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096);
+	if (blk_validate_block_size(dev->blocksize))
+		return -EINVAL;
 
 	if (dev->use_per_node_hctx) {
 		if (dev->submit_queues != nr_online_nodes)




[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