Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BAC644AB9B; Tue, 21 Jul 2026 21:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668664; cv=none; b=lwHQmtgQW1CXCbVrIjCpxldLQntUFnhbAIGo5GxjfIUKPZ5vE1D4fqE4qmFDyzFiNJefJNs+hhiJuiVzEQG1/wj5q3Qiwwzg5VYnS1Vr4LcExOPSQe4Bjj+n4Tb6+UoPWXM85gFqNaLdamDVR5zY6qCfX7qJhNBCOOLqCV6yZqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784668664; c=relaxed/simple; bh=YD1M2wdvLIvggE2PSEqpzCLC4pecfGy9Ki4K93yIcho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lA2YwpeRv/RB4roCN3LVlT9TyslKmaDXqm2NnElqtU3MX/D00THaV7YSZT88UZyn/liVHZteiJEgLPYhFKm2eWiAcp4WLT73odt8IV/Sh3jD9sPXU1JqERDFSbRYX0nbwTLHCT7sb9kYXQfe9g7P1DGAlno//0XP+Ug3dybjCRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MCwYswe2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MCwYswe2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 691351F000E9; Tue, 21 Jul 2026 21:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784668662; bh=Tlit3xRRWz5Y0CgzINSJgvdNo0aaN0olSQ2RwWLwsFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MCwYswe2eqClIe3VvfH4kEkv3swP9GkykXS+IzwmM/bUKJ0JKfkqiyE6NHWsaq2Gz MMAHkV+ijFJvZiE5KgU2c0DySX/U7Ch/6IjZyz93hvSAbnQ6uQNd2/r0oUxmfBoRrj 3tJa4TdcqZMHhMnP8HeHN1Q4x1o5NnvS0/tgIRZE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shivam Kumar , Christoph Hellwig , Sagi Grimberg , Keith Busch Subject: [PATCH 6.1 0261/1067] nvmet-tcp: Fix potential UAF when ddgst mismatch Date: Tue, 21 Jul 2026 17:14:22 +0200 Message-ID: <20260721152430.435223990@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sagi Grimberg commit dbbd07d0a7020b80f6a7028e561908f7b83b3d5a upstream. 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 Reviewed-by: Christoph Hellwig Signed-off-by: Sagi Grimberg Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1258,8 +1258,10 @@ static int nvmet_tcp_try_recv_ddgst(stru 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); nvmet_tcp_fatal_error(queue); ret = -EPROTO;