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 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: null_blk-fix-validation-of-block-size.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. commit a63318916f32e04363634013c1f4aa5c6c239ed5 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 862a9420df526..8e24fb93324cb 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1743,8 +1743,8 @@ static int null_validate_conf(struct nullb_device *dev) return -EINVAL; } - 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->queue_mode == NULL_Q_MQ && dev->use_per_node_hctx) { if (dev->submit_queues != nr_online_nodes)