From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384240; b=S006/iiLS8ARAh5LAOBHTqLG9n9xeMFq00Qnv87TPyyLddvzxo3oyCoCrR/KrH6AGkLk raVmSW74ouQ8nUlsAldyOrUPAZ23n+9qGNGA3SmTmvtz49+BCPxa6bGPkciy0mV6OiMsb ll2TJddvD0V4hSpqZD/lUt6V4QV0WIxfDommvZt+0CdM4Lv3Fw9XABG6MrK3ENk985ede XGbjObKr83ZfZbfpH8fU+iCnYtnv0Pa7AxRhhqSgPHkotFF5MJd0aMRsoPELePye52Cqd UI4kTD6vGpBMWk31he/CGqnOlvbWhzt6zFVz5gbGg/u65D87ZY3va9ixCbqSEW0RyYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384240; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=m3/fYxIIzMy1lYZ4a9MMMfRm9iwRqL012ts350HzHSw=; b=QtJwdWMEh8lEiFI7ICY+Ls3KqRo2Dxomr5Z4y71v4KtrjHk/YKPFMbDSaxtj9YD3PF3R DQhjSf5g3CQQZaAbw81l5VWeKkvcSC08Z7GPW+iXYr04l7qPQhy8fpI3EMLWci2uz/vRC KUr7IYuHr0zsDudgVEaWzpvG7cNXCgjc4YHrsZQLwibARKzuSOypSHO6H+LSW0+rQtHdL 9aSTkBP3tIeQ+/U1kcvW+Dqf1R9YhUZfirCLw6ClcfEJIxCERCkO+QoFma50OXPKU+DQQ yzu3Sz+EVmL60AyZ93il4krnel4CDUaGRPW7jqYmp8aB1QoUd5f11wlm7467eoBHlCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GI3Ac7Nw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CEB7606A322; Fri, 4 Dec 2026 11:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GI3Ac7Nw Received: by smtp.kernel.org (Postfix) with ESMTPSA id BACDA1F000C2; Fri, 4 Dec 2026 11:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384240; bh=m3/fYxIIzMy1lYZ4a9MMMfRm9iwRqL012ts350HzHSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GI3Ac7NwLd0m4fXqA3Bxvc5fZSFR157JFU83ayDPYGs9VoFT55R1CbW5tNELhQfWL PhiXG+MhGSg6v1nHTYRQdI1S6EpgLVBYf1s08DqsLZ0i48OddQvEoMUO7JRQ4I0uKY VP9EtsEz22LXrrRIeJfTZJSmKMG2KvLcmfJjmkNo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Martin Belanger , Hannes Reinecke , Keith Busch , Sasha Levin Subject: [PATCH 6.12 547/555] nvme-tcp: move the TLS record read loop into a helper Date: Fri, 4 Dec 2026 19:09:50 +0900 Message-ID: <20261204100629.414931607@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Belanger commit 76afef5e29221e68f9a19df767f94b092c31e974 upstream. Move the read loop out of nvme_tcp_skip_tls_record() into a new helper, nvme_tcp_drain_tls_record(). The next patch uses the helper to read TLS records that arrive on a live queue. No functional change. Cc: stable@vger.kernel.org Signed-off-by: Martin Belanger Reviewed-by: Hannes Reinecke Signed-off-by: Keith Busch Signed-off-by: Martin Belanger Signed-off-by: Sasha Levin --- drivers/nvme/host/tcp.c | 60 ++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 42f65263cbe59..28df8937b4379 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1648,31 +1648,16 @@ static int nvme_tcp_recv_tls_alert(struct nvme_tcp_queue *queue, } /* - * Discard a TLS record that arrived in place of the ICResp. A peer may send - * a NewSessionTicket as soon as the handshake completes. + * Read the rest of a TLS record whose first part was read into @msg. * - * Returns 0 when the record was discarded and the ICResp can be read, or a - * negative errno if the connection cannot continue. + * Returns the bytes read, or a negative errno. */ -static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue, - struct msghdr *msg, u8 ctype, int len) +static int nvme_tcp_drain_tls_record(struct nvme_tcp_queue *queue, + struct msghdr *msg, int flags) { u8 buf[NVME_TCP_TLS_REC_CHUNK]; - int ret; + int ret, drained = 0; - switch (ctype) { - case TLS_RECORD_TYPE_HANDSHAKE: - break; - case TLS_RECORD_TYPE_ALERT: - ret = nvme_tcp_recv_tls_alert(queue, msg, len); - return ret ? : -ENOTCONN; - default: - pr_err("queue %d: unhandled TLS record %u\n", - nvme_tcp_queue_id(queue), ctype); - return -ENOTCONN; - } - - /* the ICResp is in a later record, drain this one first */ while (!(msg->msg_flags & MSG_EOR)) { struct kvec iov = { .iov_base = buf, @@ -1686,16 +1671,47 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue, }; ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf), - 0); + flags); if (ret <= 0) { pr_warn("queue %d: failed to drain TLS record: %d\n", nvme_tcp_queue_id(queue), ret); return ret ? : -ECONNRESET; } + drained += ret; msg->msg_flags = drain.msg_flags; } - return 0; + return drained; +} + +/* + * Discard a TLS record that arrived in place of the ICResp. A peer may send + * a NewSessionTicket as soon as the handshake completes. + * + * Returns 0 when the record was discarded and the ICResp can be read, or a + * negative errno if the connection cannot continue. + */ +static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue, + struct msghdr *msg, u8 ctype, int len) +{ + int ret; + + switch (ctype) { + case TLS_RECORD_TYPE_HANDSHAKE: + break; + case TLS_RECORD_TYPE_ALERT: + ret = nvme_tcp_recv_tls_alert(queue, msg, len); + return ret ? : -ENOTCONN; + default: + pr_err("queue %d: unhandled TLS record %u\n", + nvme_tcp_queue_id(queue), ctype); + return -ENOTCONN; + } + + /* the ICResp is in a later record, drain this one first */ + ret = nvme_tcp_drain_tls_record(queue, msg, 0); + + return ret < 0 ? ret : 0; } /* -- 2.53.0