diff options
author | Eric Dumazet <edumazet@google.com> | 2012-09-24 07:00:11 +0000 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2014-02-10 16:10:53 -0500 |
commit | 5b377aafbb0b58c2a87f9fdae44c649aa4d79272 (patch) | |
tree | 9611d957dc292884fc17b4847fed6c5f03f98e06 /net | |
parent | 705388467e4393920abddc71dd864e0cb15e6459 (diff) |
net: guard tcp_set_keepalive() to tcp sockets
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 4b45ad8f6b9e..8ad61ba17a39 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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); |