[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180124010014.2070-2-tom@quantonium.net>
Date: Tue, 23 Jan 2018 17:00:13 -0800
From: Tom Herbert <tom@...ntonium.net>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, rohit@...ntonium.net, jchapman@...alix.com,
Tom Herbert <tom@...ntonium.net>
Subject: [PATCH net-next 1/2] kcm: Only allow TCP sockets to be attached to a KCM mux
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: syzbot+8865eaff7f9acd593945@...kaller.appspotmail.com
Signed-off-by: Tom Herbert <tom@...ntonium.net>
---
net/kcm/kcmsock.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index d4e98f20fc2a..474ea2200592 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1391,6 +1391,15 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
if (csk->sk_family == PF_KCM)
return -EOPNOTSUPP;
+ /* 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);
if (!psock)
return -ENOMEM;
--
2.11.0
Powered by blists - more mailing lists