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 52ACF2D0C94; Sat, 12 Sep 2026 19:38:55 +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=1789241936; cv=none; b=UYswFG73uND7j772zZOaWXqwWBR6yymctDrLfZy842mHjlTK3b6MfDBu7c2ZBKONy4hNpMvEEpbzDsnOYJ26Jt35mXwM4NmPD/QWJp/OQ20dsI0LVZkO4nn1NAriBkPHDPDwoXguR55UpgA9E2lbncGAZ260Rv66EuYJHDapzPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241936; c=relaxed/simple; bh=pA13WnzeFLMr/FTjgRQvyeACK9L2aBoX7eMgHhbWKgU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lqhFtc6sNua4PxQUkcOeJs4jkJl7wDFb4yu7zhQCW+bFeKKHEFBVZHs43ul2eKZ8D7Yp/YjFzcwrR3e3+t0axIL7vJkGPj0oe3ybi6g3apbDjh7bjZZD56M86mt5bl8DjEsNak140b/dwpXOibd8N5vfCgABVgFmhfg3rnA6/ic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ukUGMEhP; 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="ukUGMEhP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25E781F0089A; Sat, 12 Sep 2026 19:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789241935; bh=/Sz9qjpPflBwj4tO7Jg+0xLMZr1yTf6jYnHxoCrwHDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukUGMEhPzykX0wQKfnK0swPIaOdM80psV8q1j75Q3AkkoiTrYwDzS7NfdDm3TmUBp JGelpAICuZutOeDU8leHGziM8CwzW3YBjiUVjxnMvDgfZ/YgsOVneZGzRTPJOU0Tc1 ccY5hA1RzieBRX9oBWymcUwujO/47JWknmijxpYs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sagi Grimberg , Shivam Kumar , Keith Busch Subject: [PATCH 5.10 236/798] nvmet-tcp: reject unsolicited H2CData PDUs Date: Sat, 12 Sep 2026 08:57:44 +0200 Message-ID: <20260912065522.564337062@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Shivam Kumar commit db62b35cbca052860c519cbcabe7650708528738 upstream. nvmet_tcp_handle_h2c_data_pdu() accepts an H2CData PDU after only checking that its TTAG is a valid in-range command index and that the command's data buffers are mapped. It never checks that the target has actually solicited that data by sending an R2T for the command. A remote host can abuse this. It submits a write command that takes the R2T path and, before the target transmits the R2T, sends an H2CData PDU for that command's tag. The data completes the command early, and when the command then fails synchronously (e.g. a length mismatch caught by nvmet_check_transfer_len()), it is completed a second time. Each completion calls nvmet_tcp_queue_response(), so the same command is added to queue->resp_list twice while it is still linked; the second llist_add() makes the node point to itself (lentry->next == lentry). nvmet_tcp_process_resp_list() then walks that self-referential node and adds the command to resp_send_list twice. With CONFIG_DEBUG_LIST this trips the "list_add double add" check (kernel BUG); without it the loop never terminates and the nvmet_tcp workqueue wedges (soft-lockup). It is remotely triggerable and needs no authentication on an allow_any_host subsystem. Track whether an R2T has been transmitted for a command and reject an H2CData PDU that arrives before it. The flag is cleared on command reuse (nvmet_tcp_get_cmd() zeroes cmd->flags) and stays set across the multiple H2CData PDUs of a single solicited transfer. Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver") Cc: stable@vger.kernel.org Reviewed-by: Sagi Grimberg Signed-off-by: Shivam Kumar Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/tcp.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -51,6 +51,7 @@ enum nvmet_tcp_recv_state { enum { NVMET_TCP_F_INIT_FAILED = (1 << 0), + NVMET_TCP_F_R2T_SENT = (1 << 1), }; struct nvmet_tcp_cmd { @@ -714,6 +715,7 @@ static int nvmet_try_send_r2t(struct nvm return -EAGAIN; cmd->queue->snd_cmd = NULL; + cmd->flags |= NVMET_TCP_F_R2T_SENT; return 1; } @@ -978,6 +980,12 @@ static int nvmet_tcp_handle_h2c_data_pdu cmd = &queue->connect; } + if (unlikely(!(cmd->flags & NVMET_TCP_F_R2T_SENT))) { + pr_err("queue %d: unsolicited H2CData (ttag %u)\n", + queue->idx, data->ttag); + goto err_proto; + } + if (le32_to_cpu(data->data_offset) != cmd->rbytes_done) { pr_err("ttag %u unexpected data offset %u (expected %u)\n", data->ttag, le32_to_cpu(data->data_offset),