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=1796381468; b=IQtE5I+i+TYgqhvt7ZF6LnuCu7m1uhWh3kAnVy8sijdogZXp1OMbqjTnrmj2G3IkXlrC HYBNu4I6tCYLcl/ulHPcrCSDUWisFUWqnYHs4wE6nhjFzJAEM9w7C1Mii4rbaPJDOcI5S hoPxCHEpf4MuYksrg/IylYZpM7mD1hFtyPm3lmjaW4pTxmmdP9dM17ljq14f1/BocZmG6 bERDrC4wZQXPyKx2J/EowyAvem2eTmqWV8B0MucLJ5UaIEtq+WmZr0u/JjPellai5rXtg DKlsXNdNyLaOFX7C/YEjExIQHwZZho6a6LjebpBN0JpBB6WFCxntJa9xjp6wzRXjNQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381468; 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=Mb1Mq0X+S42AF5nQYDWd9s/AFvNK3hIRqEpiNHOLols=; b=wAfDRFENsWBpMPGOY2dMqvxMvh0i7KcEC4krCb0pzjFsSERKWjwDDmPpet9RLz6gU+Fs mmcRBwuf8v18eaMYaJg59MosdJ9ZRwCaqBujpVUAMoiTtUMizcfDqUUg8r0wB4b6a/iht mVaQqF44dj/dtOQk2q/4+8GS6GdFNp5B/6h3hGh9ibSeJ2P3Dl5r9g+ILWhJg9lavo4eJ 750xgIkf9GAO+j3P0VYntng8sQckprr2vKE04SGFJQ2KWDr4ND23+1c6HvX2IMCU1dqQ/ +XhqPxuyc0buGuKPOHkgDTiOe/K5IrC8/4E0rI+j4TpVmRWaN9qsRQBDAON+/bZ8q2Q== 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="NYoiA0o/"; 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 4C1B8606A32D; Fri, 4 Dec 2026 10:51:08 +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=NYoiA0o/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id B89011F000CE; Fri, 4 Dec 2026 10:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381468; bh=Mb1Mq0X+S42AF5nQYDWd9s/AFvNK3hIRqEpiNHOLols=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NYoiA0o/Y5iYruKRcBKi5FXqDon5i5Q8pqJc3tPz8wLAttxP8Qix7E9jitr8KO7Nx HeBAA7Ozsh3BnWUQtwJDOIWnfa3hQ0vo8dEVfUqQjsK6cnIE+PiZmfjQCQHmySUKy0 KQQISdaKYYv+oD5fp8bMQQBdfrj6rkdnROGSYkR8= 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 718/742] nvme-tcp: use an aligned buffer for the TLS record type Date: Fri, 4 Dec 2026 19:09:42 +0900 Message-ID: <20261204100654.150786867@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: 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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Belanger commit 1193566c35ead643e954ff8356bb54b1cd78378a upstream. The buffers that receive the TLS record type are char arrays. put_cmsg() and tls_get_record_type() access them as struct cmsghdr, which needs a stricter alignment than a char array has. Use a union with struct cmsghdr, sized with CMSG_SPACE(), as svc_tcp_recv_cmsg() and xs_tls_read_record() in sunrpc do. Fixes: 2837966ab2a8 ("nvme-tcp: control message handling for recvmsg()") Cc: stable@vger.kernel.org Signed-off-by: Martin Belanger Reviewed-by: Hannes Reinecke Signed-off-by: Keith Busch [ Martin: resolved a context conflict next to nvme_tcp_cpu_queues ] Signed-off-by: Martin Belanger Signed-off-by: Sasha Levin --- drivers/nvme/host/tcp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 2f30c16ec802e..0d80c12d9fe8f 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -76,6 +76,12 @@ MODULE_PARM_DESC(tls_handshake_timeout, /* TLS records read while waiting for the ICResp, the ICResp included */ #define NVME_TCP_ICRESP_MAX_RECORDS 8 +/* control message buffer for the TLS record type */ +union nvme_tcp_tls_cmsg { + struct cmsghdr cmsg; + u8 buf[CMSG_SPACE(sizeof(u8))]; +}; + static atomic_t nvme_tcp_cpu_queues[NR_CPUS]; enum nvme_tcp_send_state { @@ -1646,11 +1652,11 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue, .iov_base = buf, .iov_len = sizeof(buf), }; - char cbuf[CMSG_LEN(sizeof(char))] = {}; + union nvme_tcp_tls_cmsg u = {}; /* kTLS fails a control record read without a cmsg buffer */ struct msghdr drain = { - .msg_control = cbuf, - .msg_controllen = sizeof(cbuf), + .msg_control = &u, + .msg_controllen = sizeof(u), }; ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf), @@ -1675,7 +1681,7 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue, static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue, struct nvme_tcp_icresp_pdu *icresp) { - char cbuf[CMSG_LEN(sizeof(char))]; + union nvme_tcp_tls_cmsg u; struct msghdr msg; struct kvec iov; u8 ctype; @@ -1683,12 +1689,12 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue, for (i = 0; i < NVME_TCP_ICRESP_MAX_RECORDS; i++) { memset(&msg, 0, sizeof(msg)); - memset(cbuf, 0, sizeof(cbuf)); + memset(&u, 0, sizeof(u)); iov.iov_base = icresp; iov.iov_len = sizeof(*icresp); if (nvme_tcp_queue_tls(queue)) { - msg.msg_control = cbuf; - msg.msg_controllen = sizeof(cbuf); + msg.msg_control = &u; + msg.msg_controllen = sizeof(u); } msg.msg_flags = MSG_WAITALL; ret = kernel_recvmsg(queue->sock, &msg, &iov, 1, @@ -1696,8 +1702,7 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue, if (ret <= 0 || !nvme_tcp_queue_tls(queue)) return ret; - ctype = tls_get_record_type(queue->sock->sk, - (struct cmsghdr *)cbuf); + ctype = tls_get_record_type(queue->sock->sk, &u.cmsg); if (ctype == TLS_RECORD_TYPE_DATA) return ret; -- 2.53.0