All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dave Jones <davej@redhat.com>
Cc: Yuchung Cheng <ycheng@google.com>, Julian Anastasov <ja@ssi.bg>,
	netdev@vger.kernel.org
Subject: Re: kernel BUG at kernel/timer.c:748!
Date: Mon, 24 Sep 2012 19:00:11 +0200	[thread overview]
Message-ID: <1348506011.26828.1195.camel@edumazet-glaptop> (raw)
In-Reply-To: <1348504445.26828.1131.camel@edumazet-glaptop>

Signed-off-by: Eric Dumazet <edumazet@google.com>

On Mon, 2012-09-24 at 18:34 +0200, Eric Dumazet wrote:

> OK, I believe I found the reason. I Will post a patch.
> 
> open a raw socket AF_INET, TCP_PROTO
> + connect() ->sk_state set to TCP_ESTABLISHED
> + setsockopt( SO_KEEPALIVE, &on)  -> crash

I confirm following patch fixes the problem for me.

Thanks again

[PATCH] 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: Dave Jones <davej@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/sock.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 3057920..a6000fb 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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);

  reply	other threads:[~2012-09-24 17:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05  4:35 kernel BUG at kernel/timer.c:748! Dave Jones
2012-09-05 16:04 ` Lin Ming
2012-09-05 16:37   ` Yuchung Cheng
2012-09-05 17:08     ` Dave Jones
2012-09-05 21:18   ` Jerry Chu
2012-09-05 20:48 ` Julian Anastasov
2012-09-14 21:29   ` Dave Jones
2012-09-15 18:16     ` Yuchung Cheng
2012-09-19 21:10       ` Dave Jones
2012-09-19 22:01         ` Eric Dumazet
2012-09-20  2:02           ` Dave Jones
2012-09-24 15:39             ` Dave Jones
2012-09-24 16:34               ` Eric Dumazet
2012-09-24 17:00                 ` Eric Dumazet [this message]
2012-09-24 17:11                   ` Dave Jones
2012-09-24 17:31                     ` Eric Dumazet
2012-09-24 18:11                       ` Dave Jones
2012-09-24 20:53                         ` David Miller
2012-09-24 20:53                   ` David Miller
2012-09-24 21:01                     ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348506011.26828.1195.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davej@redhat.com \
    --cc=ja@ssi.bg \
    --cc=netdev@vger.kernel.org \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.