Skip to contentSkip to conversation

Patch "kcm: Only allow TCP sockets to be attached to a KCM mux" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Feb 23, 2018

Subsystems (2)
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

kcm: Only allow TCP sockets to be attached to a KCM mux

to the 4.9-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:
kcm-only-allow-tcp-sockets-to-be-attached-to-a-kcm-mux.patch
and it can be found in the queue-4.9 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 581e7226a5d43f629eb6399a121f85f6a15f81be Mon Sep 17 00:00:00 2001

From: Tom Herbert <[email protected]>
Date: Wed, 24 Jan 2018 12:35:40 -0800
Subject: kcm: Only allow TCP sockets to be attached to a KCM mux

From: Tom Herbert <[email protected]>

commit 581e7226a5d43f629eb6399a121f85f6a15f81be upstream.

TCP sockets for IPv4 and IPv6 that are not listeners or in closed stated are allowed to be attached to a KCM mux.

Fixes ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
Reported-by [email protected]
---
 net/kcm/kcmsock.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/kcm/kcmsock.c +7 -2
@@ -1381,8 +1381,13 @@ static int kcm_attach(struct socket *soc
 	if (!csk)
 		return -EINVAL;
 
-	/* We must prevent loops or risk deadlock ! */
-	if (csk->sk_family == PF_KCM)
+	/* Only allow TCP sockets to be attached for now */
+	if ((csk->sk_family != AF_INET && csk->sk_family != AF_INET6) ||
+	    csk->sk_protocol != IPPROTO_TCP)
+		return -EOPNOTSUPP;
+
+	/* Don't allow listeners or closed sockets */
+	if (csk->sk_state == TCP_LISTEN || csk->sk_state == TCP_CLOSE)
 		return -EOPNOTSUPP;
 
 	psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL);

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

queue-4.9/kcm-check-if-sk_user_data-already-set-in-kcm_attach.patch queue-4.9/kcm-only-allow-tcp-sockets-to-be-attached-to-a-kcm-mux.patch