nvme-core: check for too small lba shift
authorKeith Busch <kbusch@kernel.org>
Tue, 28 Nov 2023 17:36:04 +0000 (09:36 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:39 +0000 (11:51 +0100)
commita4848c45a3f01d6af48ce0101b103fcb3f251ba1
tree5b6bbb6163d983b1cf89314acda85fd73e7eb826
parent511f602527ac10344428518f4ffe78acc290529c
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@kernel.dk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/core.c