From mboxrd@z Thu Jan 1 00:00:00 1970 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 4B81840F8D8; Tue, 21 Jul 2026 19:15:09 +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=1784661310; cv=none; b=uecXF73Q1IRSXtGmcYnG9z2FKhHbBkxdeUL3+p6Hh9aYIJHT1yyPXIE0fXNPLPPFq9ZPf4MU0y62iq8YfApHyxhRXQ0j/zAFl6FPSFVYibACThMvEN8wE6PN8TzTkHLPmfCSKm1EfQmcoI64/2EG9MGb8fEfcmFkcRaARC9oaVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661310; c=relaxed/simple; bh=+2IBwwsL6PfPazNHb8qEB/W6o0+bWZkWGqrObG6hnAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FjQ+Jp6/uYTpozQyddbFPtIOFM49wmcw/eEkEGRrq/QJHKKThl6kUy45SPQFf6qr11QeUJcoqbbYetmWfUNawW/r+kNA32dlzjV46iZ+YTP86KiAP5N3yUf6XE9tnRmY+EmCjZAkiLSf3uGTJa6VebcmlneLGfIIrJIuP53+ef0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AENOgj9T; 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="AENOgj9T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B07241F000E9; Tue, 21 Jul 2026 19:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784661309; bh=opiNnDyrWWH1NupvI2Re1ODHVnNTcsBlxawJXyJ+TdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AENOgj9Tmj7540Z4nLBr/Bsd+rmyZD7RVrjWAGd/9unDslwOgixBIpf5iJJBPi181 v6j+Yusf0kCku3jeHs2yUoIaXnVu+NrxllTM5kWyK1LSv1Zuo4z700s1/TAnxxFOJK Kuj3YgH4p/pMOOrGZaQErkwH9gAio3DUHeOW2ffI= 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.12 0019/1276] nvmet-tcp: Fix potential UAF when ddgst mismatch Date: Tue, 21 Jul 2026 17:07:42 +0200 Message-ID: <20260721152446.511393394@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@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.12-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 @@ -1383,8 +1383,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;