Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e10986d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: guard tcp_set_keepalive() to tcp sockets



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: default avatarDave Jones <davej@redhat.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 69190e67
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -691,7 +691,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);