All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	sasha.levin@oracle.com, daniel@iogearbox.net,
	alexei.starovoitov@gmail.com, mkubecek@suse.cz
Subject: Re: [PATCH net 4/4] tcp: various missing rcu_read_lock around __sk_dst_get
Date: Fri, 1 Apr 2016 04:01:34 +0200	[thread overview]
Message-ID: <56FDD67E.2040904@stressinduktion.org> (raw)
In-Reply-To: <1459475124.6473.250.camel@edumazet-glaptop3.roam.corp.google.com>

On 01.04.2016 03:45, Eric Dumazet wrote:
> On Thu, 2016-03-31 at 18:39 -0700, Eric Dumazet wrote:
>> On Fri, 2016-04-01 at 03:36 +0200, Hannes Frederic Sowa wrote:
>>> On Fri, Apr 1, 2016, at 03:19, Eric Dumazet wrote:
>>>> Thanks.
>>>>
>>>> As you can see, release_sock() messes badly lockdep (once your other
>>>> patches are in )
>>>>
>>>> Once we properly fix release_sock() and/or __release_sock(), all these
>>>> false positives disappear.
>>>
>>> This was a loopback connection. I need to study release_sock and
>>> __release_sock more as I cannot currently see an issue with the lockdep
>>> handling.
>>
>> Okay, please try :
>>
>> diff --git a/net/core/sock.c b/net/core/sock.c
>> index b67b9aedb230..570dcd91d64e 100644
>> --- a/net/core/sock.c
>> +++ b/net/core/sock.c
>> @@ -2429,10 +2429,6 @@ EXPORT_SYMBOL(lock_sock_nested);
>>
>>   void release_sock(struct sock *sk)
>>   {
>> -	/*
>> -	 * The sk_lock has mutex_unlock() semantics:
>> -	 */
>> -	mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
>>
>>   	spin_lock_bh(&sk->sk_lock.slock);
>>   	if (sk->sk_backlog.tail)
>> @@ -2445,6 +2441,10 @@ void release_sock(struct sock *sk)
>>   		sk->sk_prot->release_cb(sk);
>>
>>   	sock_release_ownership(sk);
>> +	/*
>> +	 * The sk_lock has mutex_unlock() semantics:
>> +	 */
>> +	mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
>>   	if (waitqueue_active(&sk->sk_lock.wq))
>>   		wake_up(&sk->sk_lock.wq);
>>   	spin_unlock_bh(&sk->sk_lock.slock);
>
> Also take a look at commit c3f9b01849ef3bc69024990092b9f42e20df7797
>
> We might need to include the mutex_release() in sock_release_ownership()

I thought so first, as well. But given the double check for the 
spin_lock and the "mutex" we end up with the same result for the 
lockdep_sock_is_held check.

Do you see other consequences?

Thanks,
Hannes

  reply	other threads:[~2016-04-01  2:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 23:29 [PATCH net 0/4] net: fix and tighten rcu dereference checks Hannes Frederic Sowa
2016-03-31 23:29 ` [PATCH net 1/4] tun: add socket locking around sk_{attach,detach}_filter Hannes Frederic Sowa
2016-03-31 23:29 ` [PATCH net 2/4] net: proper check if we hold the socket lock during dereference Hannes Frederic Sowa
2016-03-31 23:29 ` [PATCH net 3/4] sock: use lockdep_sock_is_held were appropriate Hannes Frederic Sowa
2016-03-31 23:29 ` [PATCH net 4/4] tcp: various missing rcu_read_lock around __sk_dst_get Hannes Frederic Sowa
2016-03-31 23:39   ` Eric Dumazet
2016-04-01  0:01     ` Hannes Frederic Sowa
2016-04-01  0:12       ` Eric Dumazet
2016-04-01  0:21         ` Hannes Frederic Sowa
2016-04-01  1:19           ` Eric Dumazet
2016-04-01  1:36             ` Hannes Frederic Sowa
2016-04-01  1:39               ` Eric Dumazet
2016-04-01  1:45                 ` Eric Dumazet
2016-04-01  2:01                   ` Hannes Frederic Sowa [this message]
2016-04-01  3:13                     ` Eric Dumazet
2016-04-01  3:31                       ` Hannes Frederic Sowa
2016-04-01  1:58                 ` Hannes Frederic Sowa
2016-04-01  1:45             ` Alexei Starovoitov
2016-04-01  3:03               ` Eric Dumazet
2016-04-01  3:06                 ` Hannes Frederic Sowa
2016-04-01  4:04                 ` Alexei Starovoitov
2016-04-01  4:12                   ` Hannes Frederic Sowa
2016-04-01  4:26                     ` Alexei Starovoitov
2016-04-01  4:33                       ` Hannes Frederic Sowa
2016-04-01  8:10                         ` Daniel Borkmann
2016-04-01 18:33                           ` David Miller
2016-04-01 18:36                             ` Daniel Borkmann
2016-04-01  0:30         ` Hannes Frederic Sowa
2016-04-01  1:23           ` Eric Dumazet
2016-04-01  1:37             ` Hannes Frederic Sowa
2016-03-31 23:48 ` [PATCH net 5/4] tcp: fix rcu usage around __sk_dst_get in tcp_update_metrics Hannes Frederic Sowa
2016-03-31 23:56 ` [PATCH net 6/4] tcp: fix __sk_dst_get usage in tcp_current_mss Hannes Frederic Sowa

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=56FDD67E.2040904@stressinduktion.org \
    --to=hannes@stressinduktion.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=sasha.levin@oracle.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.