[RFC PATCH 1/4] net: Introduce read_sock_cmsg proto_ops for control message delivery

Chuck Lever <[email protected]>
Newsgroups dev.linux.lists.kernel-tls-handshake
Message-ID <[email protected]>
From: Chuck Lever <[email protected]>

Kernel TCP consumers that use the read_sock interface
(proto_ops.read_sock) cannot receive TLS control messages (Alerts,
Handshake records) when kTLS is active. The current
tls_sw_read_sock() method rejects non-data records with -EINVAL, and
the sk_read_actor_t callback has no channel for delivering record-
type metadata.

Four kernel subsystems are affected: NFSD (sunrpc svcsock), NFS
client (sunrpc xprtsock), NVMe target (nvmet-tcp), and NVMe host
(nvme-tcp). Each of these either falls back to the slower
sock_recvmsg() API or lacks TLS alert handling entirely.

A new read_sock_cmsg method in struct proto_ops provides a separate
code path that delivers non-data TLS records to a callback, without
changing the existing read_sock behavior used by consumers of the
existing read_sock method.

The new sk_read_cmsg_actor_t callback type extends the
sk_read_actor_t signature with a content_type parameter carrying the
protocol-layer record type (for example, TLS_RECORD_TYPE_ALERT).

Signed-off-by: Chuck Lever <[email protected]>
---
 include/linux/net.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/net.h b/include/linux/net.h
index f58b38ab37f8..94eb1c3c1cb6 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -154,6 +154,10 @@ struct sk_buff;
 struct proto_accept_arg;
 typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
 			       unsigned int, size_t);
+typedef int (*sk_read_cmsg_actor_t)(read_descriptor_t *,
+				    struct sk_buff *,
+				    unsigned int, size_t,
+				    u8 content_type);
 typedef int (*skb_read_actor_t)(struct sock *, struct sk_buff *);
 
 
@@ -218,6 +222,10 @@ struct proto_ops {
 	 */
 	int		(*read_sock)(struct sock *sk, read_descriptor_t *desc,
 				     sk_read_actor_t recv_actor);
+	int		(*read_sock_cmsg)(struct sock *sk,
+					  read_descriptor_t *desc,
+					  sk_read_actor_t recv_actor,
+					  sk_read_cmsg_actor_t cmsg_actor);
 	/* This is different from read_sock(), it reads an entire skb at a time. */
 	int		(*read_skb)(struct sock *sk, skb_read_actor_t recv_actor);
 	int		(*sendmsg_locked)(struct sock *sk, struct msghdr *msg,
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.