Skip to contentSkip to conversation

Patch "net/tls: Only attach to sockets in ESTABLISHED state" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Jan 28, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net/tls: Only attach to sockets in ESTABLISHED state

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-tls-only-attach-to-sockets-in-established-state.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Sun Jan 28 17:35:08 CET 2018

From: Ilya Lesokhin <[email protected]>
Date: Tue, 16 Jan 2018 15:31:52 +0200
Subject: net/tls: Only attach to sockets in ESTABLISHED state

From: Ilya Lesokhin <[email protected]>

[ Upstream commit d91c3e17f75f218022140dee18cf515292184a8f ]

Calling accept on a TCP socket with a TLS ulp attached results in two sockets that share the same ulp context.
The ulp context is freed while a socket is destroyed, so after one of the sockets is released, the second second will trigger a use after free when it tries to access the ulp context attached to it.
We restrict the TLS ulp to sockets in ESTABLISHED state to prevent the scenario above.

Fixes 3c4d7559159b ("tls: kernel TLS support")
Reported-by [email protected]
---
 net/tls/tls_main.c |    9 +++++++++
 1 file changed, 9 insertions(+)
net/tls/tls_main.c +9 -0
@@ -444,6 +444,15 @@ static int tls_init(struct sock *sk)
 	struct tls_context *ctx;
 	int rc = 0;
 
+	/* The TLS ulp is currently supported only for TCP sockets
+	 * in ESTABLISHED state.
+	 * Supporting sockets in LISTEN state will require us
+	 * to modify the accept implementation to clone rather then
+	 * share the ulp context.
+	 */
+	if (sk->sk_state != TCP_ESTABLISHED)
+		return -ENOTSUPP;
+
 	/* allocate tls context */
 	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx) {

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/net-tls-only-attach-to-sockets-in-established-state.patch