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=1796384238; b=T2tDVFyVR9Wd7laFAeWrUaeG/sXM8cu6IVXFZiGgIF4XNahMNRvhL6XHk1d7sj1vK1v6 uYPjL7QxMq9YB3oeLkNEYWQPyPnjGtkrf328uUhGgiQaEuglPeTh+CIbObKV+lIw6faoR EHQwDfZyvnVqP7jbeHanZsD4JwR4liGaLoiiyQwgJRoZyj9/UOu+8sWV3Q4XYF3GKRI2g 4afaEJoGXelhzYaiU3enwrzvWgNRpg12QNIColLYXyKgdTkYvgT5/3pCNDWLmxbHUNS0d qlNFqfPfWWMhMUQ1xehPCh+x1keRl3nGwaQT1JvELaw14smEteyTVfedBE1w4agTHDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384238; 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=NTzZCFe37M88MWyxddCFVcyf1NUvFMrNh2DpTNEitAQ=; b=BeTTiynqNeh+5Yzfl6QBH5yQ8+U0qXTBhpMaO4OX56VMxC3YinAN2UVrA1Fp2FT/+EXv 1YV44yS+sn5a7CeuE8/Vf+jXg3TBXlMcdNI4kelARMT6RcTcMKpYlz8oidU0tfZAq8QBS RJJiCR4cz4oP5E/S9fGzkgii1UT1p44Cf/Kk097UFr9oeIfCmYJubMPa/vq0NSHvWZxBu uWU12JITEENItdOCHaWT/La35MRUwT2yik/wxWlflrWpYWiXKBjDRYW3mXQdumM1RAAu2 7Ha+aG+a/y/SFoBvvMQZlsQAVo1clL7RK0F4Icm01F5+gUSRXM5fQ6HwV+J/j9O8jAg== 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=oxPHaz48; 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 E9089606A32C; Fri, 4 Dec 2026 11:37:17 +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=oxPHaz48 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 614F51F000C2; Fri, 4 Dec 2026 11:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384237; bh=NTzZCFe37M88MWyxddCFVcyf1NUvFMrNh2DpTNEitAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oxPHaz48XTEV7G69C9F67T2pMl7HUoPzPbeg2Vj/oruhvwugLTgZY88BSoQ7p9h+W rs9FiGbaG7jL/sAYBSyFUF5Fy8ESrHECoiVL9NjgYxCg51R7kUm+HHiDFmZcvlTKSd IYEYSr0OpR4IHfClfZwQjaRmogGDbprMdpw2Edfg= 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 546/555] nvme-tcp: use an aligned buffer for the TLS record type Date: Fri, 4 Dec 2026 19:09:49 +0900 Message-ID: <20261204100629.388205853@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 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 3d89e20dfe3e0..42f65263cbe59 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]; #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -1672,11 +1678,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), @@ -1701,7 +1707,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; @@ -1709,12 +1715,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, @@ -1722,8 +1728,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