]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: guard tcp_set_keepalive() to tcp sockets
authorEric Dumazet <edumazet@google.com>
Mon, 24 Sep 2012 07:00:11 +0000 (07:00 +0000)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Mon, 10 Feb 2014 21:10:53 +0000 (16:10 -0500)
commit 3e10986d1d698140747fcfc2761ec9cb64c1d582 upstream.

Its possible to use RAW sockets to get a crash in
tcp_set_keepalive() / sk_reset_timer()

Fix is to make sure socket is a SOCK_STREAM one.

Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
net/core/sock.c

index 4b45ad8f6b9e3d26387a9aac78462878c838b08d..8ad61ba17a39e736aeaa63cc56f9c7b4c99e289a 100644 (file)
@@ -582,7 +582,8 @@ set_rcvbuf:
 
        case SO_KEEPALIVE:
 #ifdef CONFIG_INET
-               if (sk->sk_protocol == IPPROTO_TCP)
+               if (sk->sk_protocol == IPPROTO_TCP &&
+                   sk->sk_type == SOCK_STREAM)
                        tcp_set_keepalive(sk, valbool);
 #endif
                sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);