From: Eric Dumazet Date: Mon, 24 Sep 2012 07:00:11 +0000 (+0000) Subject: net: guard tcp_set_keepalive() to tcp sockets X-Git-Tag: v2.6.32.61~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2e244fabae264798ac7980a3d3056ba1684a187;p=people%2Fms%2Flinux.git net: guard tcp_set_keepalive() to tcp sockets [ Upstream commit 3e10986d1d698140747fcfc2761ec9cb64c1d582 ] 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 Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Signed-off-by: Willy Tarreau --- diff --git a/net/core/sock.c b/net/core/sock.c index 4538a34af2a0..eafa660832d7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -562,7 +562,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);