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 B96D52D8DDF; Mon, 17 Aug 2026 14:03:00 +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=1786975381; cv=none; b=LC/Qo2JWMBjYsRM8q970G2IJB174UfNtzYynN9lx5YGChzr+9glLoxmVClSurkNMuD2dsb3bj2LkFrzkmCDCI/GtykgLa/sIplXfyTVrfbksRElNZ+LA/1Ba/Dv4dzWUC+dgTBU616ragfv4QhAKnHTCSbIxb5v/3qGQZreOW2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975381; c=relaxed/simple; bh=hnOAQsX3noLf7xOj3BUTbNnDkL7kmIQoN1iHdm1BBBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hwfi8W9VeLO3NaaxEhELkOYdA2jTcnVi8RUDSEnx220FRBhf21YMwSsG6B7lngT3Z/r1fENbENhldlllLJZ0brduC5oDE1h72DzwWH4tA7JOdmdR0SPHLzvQouKalGM7C94ZQeVETV9vVMpwwQ5/20iMFP7xNZNYIsp2ygrYqXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NHMmsbo/; 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="NHMmsbo/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F2F21F000E9; Mon, 17 Aug 2026 14:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786975380; bh=86Is0yd5y4b6YRaH+yHJaXsAyF2SDnc4q/P1flDEsSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NHMmsbo/BtP0z6dXqEN0n6rM9WD+xwar5Wn42cNVIImfRoCmYI/vA0mcPoEUSzGxk 6yJEKEI74KXpkqCeQmjoaIHWkhbtHIhRX2nFdvcGi8Kn6hwjLk2TKgf1sRDK9W5Y7H vd778hqksuzKHnJnyY0hGcd0ypAOW6nhhHOSYdk0= 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 , Sasha Levin Subject: [PATCH 5.10 001/389] nvmet-tcp: Fix potential UAF when ddgst mismatch Date: Mon, 17 Aug 2026 15:27:20 +0200 Message-ID: <20260817132538.864521477@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@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-Transfer-Encoding: 8bit 5.10-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: Shivam Kumar Signed-off-by: Sasha Levin --- 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 3d9a830950ef26..27d001fd882168 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1227,8 +1227,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); nvmet_tcp_fatal_error(queue); ret = -EPROTO; -- 2.53.0