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=1796382903; b=YB2Q2aX+bnh9EznmZ6km/8FNF+KWrHbzwgO4i+PMqUJ4cxhfkSZ9eSR0YRIfIH/qcWgD hO7Dg2a8/ZFtLCBCSxkIwPZoD4rgLqFL11cFmI6LjCjJ03wzeSTfqG5/U2R11MOArb45G KngZj0igm1aKrvD7ZACYFPDwLDDyioviwhGHEjbp23ad/xnLo+OhoPZqykmKDYfgJ8cvB bT2lJxgcnVjG8Z8MWQqNqELFn7Z1Xcg+7O3j4yEOBOeLaLmhFAe6t8XBIzCAeA9x1SIEg UV7xrFvjynY2O/FEnJY7vZNMgysqEL0IzMkWafZhnqE5uY4UuchxXq7wBy1CXtGNFtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382903; 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=zg5PbawlucC63ymeg1Tdk4/fj1W6mtTlhLekaGBfiuM=; b=S/zBx2cVE+uaknuOI55tU5Ny28e9t4ThoDpvU5pdE0pRLrksIrwOPNe3gfTjqbCXKxla wGel0MjPHLnoJjB742MTLOhC5r3VMHQ04xYhTzGtfhp+Ynt4FgATvafdDokLXmwA+V5Pp nmyUgcvZjW6WoPG6a6tVQ/p2LEI3ACeCOxD3fewbYFouj5GJKe8tUFNdwHhqw945YHMgI Awadu771ewSQlG7hRLw+OnveulyJRtqwMxDUcoIbPSxE1eGVR32PpziBMQzFasZWpUE/E HGDwO7hRk6PFAnOzn/XcPjTnHoLi1X0DsQegKzozFeYKBONvu/xxmWJ+xmOoUp0Lxtw== 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=2olS1yP7; 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 683B0606A330; Fri, 4 Dec 2026 11:15:03 +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=2olS1yP7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77A101F000C2; Fri, 4 Dec 2026 11:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382902; bh=zg5PbawlucC63ymeg1Tdk4/fj1W6mtTlhLekaGBfiuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2olS1yP7lhk9Nt6ikB1NmLoJnDsIMwpG17Xtq0qQykcnNRio10/v6xrCqpkB8R8it 2NgFSpTy8HQEjcinN8pizuwSlOED7AiAywsrOciZR4K0Vfy30iYEOkG8p9qz3CFCor 8RqfpvU8Cd6owwDRhDQwY87CUsxLLsKPGitye2Rg= 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.18 644/703] nvme-tcp: move the TLS record read loop into a helper Date: Fri, 4 Dec 2026 19:09:03 +0900 Message-ID: <20261204100644.919741079@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 6d3bf57371fbd..d192edb701afd 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1614,31 +1614,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, @@ -1652,16 +1637,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