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 5DA8541F7C3; Tue, 21 Jul 2026 22:23:23 +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=1784672604; cv=none; b=T7cNNmS99/kvXWpwqk93WnSN2jPE/g4yvAxLA37cQwkk/lGrZcY5+c/Ge6jxsKNlIvLhYE/fcKoelznadAQqNstl3SQAh0/GnRxcmLtuN/JFIQKV1/sm7Ix+eJgi+yH3pGNOfvi8rexHQ2I+aucIzUS2tsxGgZYVolwaSYqHWUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672604; c=relaxed/simple; bh=s1aEaX1ySzoRgzbh29Wh2pOa3vvfW2A4ohxQ8x3NjBM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JSnInfodTaiISdMqakpUYT8JDqk9B/8ntDuF5skwKyich2ZlvpZM+uThw0t/au+BOsoCV1u1+jTxtFBIu0c+DQD7PDSeYq/3JzWfusmldFYG4YDB7zsegqVWlujnUW8dDGj3ewvVgprox3PholEWq/bMuozS1Z/nyC6ACg1Fh7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=14EjHjVp; 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="14EjHjVp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C6E51F00A3A; Tue, 21 Jul 2026 22:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672602; bh=eJyNHu58nc2WL6KjNVWqQeCVxhSkY05dwZUIcx1izZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=14EjHjVp/Qe8NNFcFeZ/i9j9WS02X6AWJwAu3I/ZYHSe2W1T2isNfeLoCUb5TEYTg nBkKAYeosUkGA+3xFLJRgPZNDBosERlsvVKmDwY0Rrur+M7Z0w21Z4DYInVTQlaXUg KnlCIgTdyL5Q8UjbBaiDy6cMm99B7iXWih/fsrwk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Shivam Kumar , Keith Busch , Sasha Levin Subject: [PATCH 5.15 688/843] nvmet-tcp: check INIT_FAILED before nvmet_req_uninit in digest error path Date: Tue, 21 Jul 2026 17:25:23 +0200 Message-ID: <20260721152421.531899170@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shivam Kumar commit 4606467a75cfc16721937272ed29462a750b60c8 upstream. In nvmet_tcp_try_recv_ddgst(), when a data digest mismatch is detected, nvmet_req_uninit() is called unconditionally. However, if the command arrived via the nvmet_tcp_handle_req_failure() path, nvmet_req_init() had returned false and percpu_ref_tryget_live() was never executed. The unconditional percpu_ref_put() inside nvmet_req_uninit() then causes a refcount underflow, leading to a WARNING in percpu_ref_switch_to_atomic_rcu, a use-after-free diagnostic, and eventually a permanent workqueue deadlock. Check cmd->flags & NVMET_TCP_F_INIT_FAILED before calling nvmet_req_uninit(), matching the existing pattern in nvmet_tcp_execute_request(). Reviewed-by: Christoph Hellwig Signed-off-by: Shivam Kumar Signed-off-by: Keith Busch [shivam: inlined nvmet_tcp_finish_cmd() at the fix site for 5.15.y] 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 06cfcf0850076b..95081052dce78f 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1239,7 +1239,9 @@ 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)); - nvmet_tcp_finish_cmd(cmd); + if (!(cmd->flags & NVMET_TCP_F_INIT_FAILED)) + nvmet_req_uninit(&cmd->req); + nvmet_tcp_free_cmd_buffers(cmd); nvmet_tcp_fatal_error(queue); ret = -EPROTO; goto out; -- 2.53.0