Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-fc: initialize result on transport failure
@ 2026-11-29 13:52 Andrew Stellman
  2026-11-30  8:48 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-29 13:52 UTC (permalink / raw)
  To: Justin Tee, Naresh Gottumukkala, Paul Ely, Keith Busch,
	Christoph Hellwig, Sagi Grimberg
  Cc: Jens Axboe, linux-nvme

From: Andrew Stellman <astellman@stellman-greene.com>

nvme_fc_fcpio_done() declares result without an initializer. When a
command is aborted, it jumps to done without assigning result and
passes it to nvme_try_complete_req(). For a passthrough command, the
ioctl then copies that value to user space along with the host aborted
status.

Initialize result to zero. The success paths still assign it.

Tested on a mainline 7.4.0-rc4 snapshot in an arm64 QEMU guest with
CONFIG_INIT_STACK_NONE=y, CONFIG_KASAN=y and NVMe/FC loopback (fcloop).
Root gave other users read access to /dev/nvme0, and a non-root user
then sent Identify Controller with a 1500 ms timeout while fcloop
dropped the command. Without the patch the ioctl returned status 0x371
(host aborted) and a nonzero result, in two boots. With the patch the
result was 0 in one boot. Identify without a drop returned status 0 and
result 0 in every boot.

The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.

Fixes: 27fa9bc54541 ("nvme: split nvme status from block req->errors")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
A reproducer is available on request.

 drivers/nvme/host/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 2cbd744ffd22a..978ec029ac950 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1902,7 +1902,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 	struct nvme_completion *cqe = &op->rsp_iu.cqe;
 	struct nvme_command *sqe = &op->cmd_iu.sqe;
 	__le16 status = cpu_to_le16(NVME_SC_SUCCESS << 1);
-	union nvme_result result;
+	union nvme_result result = {};
 	bool terminate_assoc = true;
 	int opstate;
 
-- 
2.53.0



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

end of thread, other threads:[~2026-11-30  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 13:52 [PATCH] nvme-fc: initialize result on transport failure Andrew Stellman
2026-11-30  8:48 ` Christoph Hellwig

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