mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Anastasov <ja@ssi.bg>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
	David Miller <davem@davemloft.net>,
	networking <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: IPv4 BUG: held lock freed!
Date: Sun, 19 Aug 2012 19:51:41 +0300 (EEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1208191647340.1893@ja.ssi.bg> (raw)
In-Reply-To: <1345380682.5158.201.camel@edumazet-glaptop>


	Hello,

On Sun, 19 Aug 2012, Eric Dumazet wrote:

> Hmm, this looks like sk_reset_timer() is called on a socket, and timer
> triggers _before_ the sock_hold()
> 
> So the timer handler decrements sk_refcnt to 0 and calls sk_free()
> 
> Its probably a bug introduced (or uncovered) by commit 6f458dfb40 (tcp:
> improve latencies of timer triggered events)
> 
> I always found sk_reset_timer() a bit racy...
> 
> void sk_reset_timer(struct sock *sk, struct timer_list* timer,
>                     unsigned long expires)
> {
> 	if (!mod_timer(timer, expires))
> 		sock_hold(sk); // MIGHT BE TOO LATE
> }
> 
> Following should be safer...

	Above code is fine as long as caller holds reference.

	Your change for tcp_release_cb looks correct.

	Also, may be tcp_v4_mtu_reduced is missing a check
for TCP_CLOSE state? tcp_v6_mtu_reduced already has such
check.

> void sk_reset_timer(struct sock *sk, struct timer_list* timer,
>                     unsigned long expires)
> {

	This should not be needed:

> 	sock_hold(sk);
> 	if (mod_timer(timer, expires))
> 		sock_put(sk);
> }

Regards

--
Julian Anastasov <ja@ssi.bg>

      parent reply	other threads:[~2012-08-19 16:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-18  2:19 Fengguang Wu
2012-08-19  3:39 ` Fengguang Wu
2012-08-19 12:51 ` Eric Dumazet
2012-08-19 13:04   ` Fengguang Wu
2012-08-19 14:15   ` Lin Ming
2012-08-19 14:45     ` Eric Dumazet
2012-08-19 15:05       ` Lin Ming
2012-08-19 15:55         ` Eric Dumazet
2012-08-19 16:51   ` Julian Anastasov [this message]

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=alpine.LFD.2.00.1208191647340.1893@ja.ssi.bg \
    --to=ja@ssi.bg \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®