Patch "nvme-core: check for too small lba shift" has been added to the 5.10-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

    nvme-core: check for too small lba shift

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:
     nvme-core-check-for-too-small-lba-shift.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 5f9b0a0e799278756282559a60b55f8088bc752e
Author: Keith Busch <kbusch@xxxxxxxxxx>
Date:   Tue Nov 28 09:36:04 2023 -0800

    nvme-core: check for too small lba shift
    
    [ Upstream commit 74fbc88e161424b3b96a22b23a8e3e1edab9d05c ]
    
    The block layer doesn't support logical block sizes smaller than 512
    bytes. The nvme spec doesn't support that small either, but the driver
    isn't checking to make sure the device responded with usable data.
    Failing to catch this will result in a kernel bug, either from a
    division by zero when stacking, or a zero length bio.
    
    Reviewed-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 07c41a149328..30a642c8f537 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2071,9 +2071,10 @@ static void nvme_update_disk_info(struct gendisk *disk,
 
 	/*
 	 * The block layer can't support LBA sizes larger than the page size
-	 * yet, so catch this early and don't allow block I/O.
+	 * or smaller than a sector size yet, so catch this early and don't
+	 * allow block I/O.
 	 */
-	if (ns->lba_shift > PAGE_SHIFT) {
+	if (ns->lba_shift > PAGE_SHIFT || ns->lba_shift < SECTOR_SHIFT) {
 		capacity = 0;
 		bs = (1 << 9);
 	}




[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