[PATCH v2 0/2] nvmet: fix file backend short I/O and LBA range checks
From: shao.mingyin
Date: Thu Nov 12 2026 - 09:09:09 EST
The file backend computes byte offsets from the LBA and block size with
unchecked 64-bit arithmetic and does not handle short reads or writes.
A host can therefore make the backend report success for a transfer that
only covered part of the range, and a large LBA or length can wrap the
range check and reach vfs_fallocate() with an out-of-range offset.
Patch 1 makes nvmet_file_execute_io() stop at an incomplete submit
instead of advancing the position and eventually reporting success, and
converts a zero-byte completion on the common path to -EIO. Patch 2
adds a shared overflow-safe range check and uses it for read, write,
discard and write zeroes.
The two patches are independent and can be applied in any order. Both
carry Fixes: and Cc: stable.
Changes in v2 (Christoph Hellwig):
- Patch 2: use the shared LBA range helper for reads and writes, with
pos64 local to the helper. No functional change from v1.
- Patch 1: unchanged; add Christoph Hellwig's Reviewed-by tag.
Link to v1: https://lore.kernel.org/all/20261111224134934XG6vMtntrNJQL1ztj7imr@xxxxxxxxxx/
Shao Mingyin (2):
nvmet: handle short reads and writes in the file backend
nvmet: use overflow-safe range checks in the file backend
drivers/nvme/target/io-cmd-file.c | 47 ++++++++++++++++++++++++++++-----------
1 file changed, 34 insertions(+), 13 deletions(-)
---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b