aboutsummaryrefslogtreecommitdiffstats
path: root/net/handshake/tlshd.c
diff options
context:
space:
mode:
authorJakub Kicinski <[email protected]>2023-07-28 21:08:01 +0000
committerJakub Kicinski <[email protected]>2023-07-28 21:08:02 +0000
commit05191d8896b42cacb4551409b482d321b4321eff (patch)
tree73d34fe08c5127f99428be7f39ef1ed22b6a36e2 /net/handshake/tlshd.c
parentocteontx2-af: Initialize 'cntr_val' to fix uninitialized symbol error (diff)
parentnet/handshake: Trace events for TLS Alert helpers (diff)
downloadkernel-05191d8896b42cacb4551409b482d321b4321eff.tar.gz
kernel-05191d8896b42cacb4551409b482d321b4321eff.zip
Merge branch 'in-kernel-support-for-the-tls-alert-protocol'
Chuck Lever says: ==================== In-kernel support for the TLS Alert protocol IMO the kernel doesn't need user space (ie, tlshd) to handle the TLS Alert protocol. Instead, a set of small helper functions can be used to handle sending and receiving TLS Alerts for in-kernel TLS consumers. ==================== Merged on top of a tag in case it's needed in the NFS tree. Link: https://lore.kernel.org/r/169047923706.5241.1181144206068116926.stgit@oracle-102.nfsv4bat.org Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/handshake/tlshd.c')
-rw-r--r--net/handshake/tlshd.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/net/handshake/tlshd.c b/net/handshake/tlshd.c
index b735f5cced2f..bbfb4095ddd6 100644
--- a/net/handshake/tlshd.c
+++ b/net/handshake/tlshd.c
@@ -18,6 +18,7 @@
#include <net/sock.h>
#include <net/handshake.h>
#include <net/genetlink.h>
+#include <net/tls_prot.h>
#include <uapi/linux/keyctl.h>
#include <uapi/linux/handshake.h>
@@ -100,6 +101,9 @@ static void tls_handshake_done(struct handshake_req *req,
if (info)
tls_handshake_remote_peerids(treq, info);
+ if (!status)
+ set_bit(HANDSHAKE_F_REQ_SESSION, &req->hr_flags);
+
treq->th_consumer_done(treq->th_consumer_data, -status,
treq->th_peerid[0]);
}
@@ -424,3 +428,22 @@ bool tls_handshake_cancel(struct sock *sk)
return handshake_req_cancel(sk);
}
EXPORT_SYMBOL(tls_handshake_cancel);
+
+/**
+ * tls_handshake_close - send a Closure alert
+ * @sock: an open socket
+ *
+ */
+void tls_handshake_close(struct socket *sock)
+{
+ struct handshake_req *req;
+
+ req = handshake_req_hash_lookup(sock->sk);
+ if (!req)
+ return;
+ if (!test_and_clear_bit(HANDSHAKE_F_REQ_SESSION, &req->hr_flags))
+ return;
+ tls_alert_send(sock, TLS_ALERT_LEVEL_WARNING,
+ TLS_ALERT_DESC_CLOSE_NOTIFY);
+}
+EXPORT_SYMBOL(tls_handshake_close);