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=1796381470; b=iHCrqEYpIivtCUy/nsQiJOjFkvEX9hbfE+tj1FBTPZpob+nLD1qPqWssPGOc5iektsog 86xf2C/ENSRPkbaB/Vd/lMpz6cvk+yB0pCMpUN4Ma8KW8WJNZJFmxsFI+FbMLcb9tapIL /g+bzT+eI/SfBgdk15zDX8oFPUvPMiysNFtlVMOMm04f/cMoqqGfMfLS4TU/A4fElBQmb DGFMg7FnkZ8Q0ZGSH8WbQVrL8hcQq/3RYh+hWThRiU7Y6fY9zo9yrhgK0C/XohpznBfQU qqEErwLfajz+mvfj6LtWe8yQFdBal+Xk9OwoMiAh/qaMBLH8F+wmNDlwIPKcSG0dLPw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381470; 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=Rt/TZHqVmKVVXsRpUkBTS+9wB43wBbWe3v2VR4g3y9g=; b=zQsdZP1kYEhGVAms6YHHN7M2q+RW3rGYVs6BqeyGLIDvgqRinWLSyoZb920tD7lc/3P+ ZqbsXF8sqsz4z6pT/dWxNipArozKTPScN/SMqyz5jL90SXupa1AwsSy2mPjZTKnnVnO8S tpiMJsV9IBFosWhWENP7Hy4PtOOae7ErbPLCCd62QmGpBiDxwafkF1wgpInsOZVrbsXRM uuYWLbDde6eC+nYqyO+Um0Q+XDSu0Cx5QbXVTQlCF+MRU5qsT5Wa/X8xkTg0pFMYM2hpk NOA07UzlrXJgiEk25jUDdQ4gJcogZN5/Zml0cFjqRPbL/ai/OjXyaMZJFgSUfL55mzw== 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=avg6XHyZ; 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 D3D97606A32C; Fri, 4 Dec 2026 10:51:10 +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=avg6XHyZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 045201F000C2; Fri, 4 Dec 2026 10:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381470; bh=Rt/TZHqVmKVVXsRpUkBTS+9wB43wBbWe3v2VR4g3y9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=avg6XHyZtj1JB/TMW5cfcUeNgkGC4Yv3P9aNt8Z1jujnxDPuC+dP4yNCEMTtVLt2m s+QrW/vO7nmoLk4wYK3NwThwqzW6sNp64BYiyS/cBtaB2sgZzH1HMiemtkf30VdBWc gwbyTrUHvZSraNlevo/qyViBeColBwxb7I5gm+Rg= 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 7.3 719/742] nvme-tcp: move the TLS record read loop into a helper Date: Fri, 4 Dec 2026 19:09:43 +0900 Message-ID: <20261204100654.177617257@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-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 0d80c12d9fe8f..ea64d243d058b 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1622,31 +1622,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, @@ -1660,16 +1645,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