mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] nvmet: fix file backend short I/O and LBA range checks
@ 2026-11-11 14:41 shao.mingyin
  2026-11-11 14:42 ` [PATCH 1/2] nvmet: handle short reads and writes in the file backend shao.mingyin
  2026-11-11 14:42 ` [PATCH 2/2] nvmet: use overflow-safe range checks " shao.mingyin
  0 siblings, 2 replies; 5+ messages in thread
From: shao.mingyin @ 2026-11-11 14:41 UTC (permalink / raw)
  To: kbusch, axboe, hch, sagi, linux-nvme; +Cc: linux-kernel, stable

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.

Testing: both were tested on 7.3.0-next-20261030 with the loop transport
and a file-backed namespace under QEMU/TCG.  Patch 1 used failslab to
reach the chunked path and a shortened backing file to force an
incomplete chunk; the unpatched target returned 0 with the tail of the
host buffer unchanged and only part of the write reaching the file, and
all four cases return 0x6006 after the patch.  Patch 2 wrote SLBA 2^52+1
with a 4096-byte block size, which wraps to offset 0x1000; the unpatched
target accepted the command, and it now fails with 0x6081 (Capacity
Exceeded).  Both patches also apply to next-20261105 and pass
checkpatch.pl --strict with no errors.

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 | 48 ++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 13 deletions(-)

---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-11 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 14:41 [PATCH 0/2] nvmet: fix file backend short I/O and LBA range checks shao.mingyin
2026-11-11 14:42 ` [PATCH 1/2] nvmet: handle short reads and writes in the file backend shao.mingyin
2026-11-11 16:41   ` Christoph Hellwig
2026-11-11 14:42 ` [PATCH 2/2] nvmet: use overflow-safe range checks " shao.mingyin
2026-11-11 16:43   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®