* [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch
@ 2026-05-10 20:30 Sagi Grimberg
2026-05-11 6:20 ` Christoph Hellwig
2026-05-11 14:59 ` Keith Busch
0 siblings, 2 replies; 3+ messages in thread
From: Sagi Grimberg @ 2026-05-10 20:30 UTC (permalink / raw)
To: linux-nvme
Cc: Shivam Kumar, Christoph Hellwig, Keith Busch, Chaitanya Kulkarni,
security
Shivam Kumar found via vulnerability testing:
When data digest is enabled on an NVMe/TCP connection and a digest
mismatch occurs on a non-final H2C_DATA PDU during an R2T-based
data transfer, the digest error handler in nvmet_tcp_try_recv_ddgst()
calls nvmet_req_uninit() — which performs percpu_ref_put() on the
submission queue — but does NOT mark the command as completed. It
does not set cqe->status, does not modify rbytes_done, and does not
clear any flag. When the subsequent fatal error triggers queue
teardown, nvmet_tcp_uninit_data_in_cmds() iterates all commands,
checks nvmet_tcp_need_data_in() for each one, and finds that the
already-uninited command still appears to need data (because
rbytes_done < transfer_len and cqe->status == 0). It therefore calls
nvmet_req_uninit() a second time on the same command — a double
percpu_ref_put against a single percpu_ref_get.
Reported-by: Shivam Kumar <kumar.shivam43666@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/target/tcp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 164a564ba3b4..20f150d17a96 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1321,8 +1321,10 @@ static int nvmet_tcp_try_recv_ddgst(struct nvmet_tcp_queue *queue)
queue->idx, cmd->req.cmd->common.command_id,
queue->pdu.cmd.hdr.type, le32_to_cpu(cmd->recv_ddgst),
le32_to_cpu(cmd->exp_ddgst));
- if (!(cmd->flags & NVMET_TCP_F_INIT_FAILED))
+ if (!(cmd->flags & NVMET_TCP_F_INIT_FAILED)) {
+ cmd->req.cqe->status = NVME_SC_CMD_SEQ_ERROR;
nvmet_req_uninit(&cmd->req);
+ }
nvmet_tcp_free_cmd_buffers(cmd);
ret = -EPROTO;
goto out;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch
2026-05-10 20:30 [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch Sagi Grimberg
@ 2026-05-11 6:20 ` Christoph Hellwig
2026-05-11 14:59 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-05-11 6:20 UTC (permalink / raw)
To: Sagi Grimberg
Cc: linux-nvme, Shivam Kumar, Christoph Hellwig, Keith Busch,
Chaitanya Kulkarni, security
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch
2026-05-10 20:30 [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch Sagi Grimberg
2026-05-11 6:20 ` Christoph Hellwig
@ 2026-05-11 14:59 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2026-05-11 14:59 UTC (permalink / raw)
To: Sagi Grimberg
Cc: linux-nvme, Shivam Kumar, Christoph Hellwig, Chaitanya Kulkarni,
security
On Sun, May 10, 2026 at 11:30:29PM +0300, Sagi Grimberg wrote:
> Shivam Kumar found via vulnerability testing:
> When data digest is enabled on an NVMe/TCP connection and a digest
> mismatch occurs on a non-final H2C_DATA PDU during an R2T-based
> data transfer, the digest error handler in nvmet_tcp_try_recv_ddgst()
> calls nvmet_req_uninit() - which performs percpu_ref_put() on the
> submission queue - but does NOT mark the command as completed. It
> does not set cqe->status, does not modify rbytes_done, and does not
> clear any flag. When the subsequent fatal error triggers queue
> teardown, nvmet_tcp_uninit_data_in_cmds() iterates all commands,
> checks nvmet_tcp_need_data_in() for each one, and finds that the
> already-uninited command still appears to need data (because
> rbytes_done < transfer_len and cqe->status == 0). It therefore calls
> nvmet_req_uninit() a second time on the same command - a double
> percpu_ref_put against a single percpu_ref_get.
Thanks, applied to nvme-7.1.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10 20:30 [PATCH] nvmet-tcp: Fix potential UAF when ddgst mismatch Sagi Grimberg
2026-05-11 6:20 ` Christoph Hellwig
2026-05-11 14:59 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox