Skip to content

Commit

Permalink
sock: fix lockdep annotation in release_sock
Browse files Browse the repository at this point in the history
During release_sock we use callbacks to finish the processing
of outstanding skbs on the socket. We actually are still locked,
sk_locked.owned == 1, but we already told lockdep that the mutex
is released. This could lead to false positives in lockdep for
lockdep_sock_is_held (we don't hold the slock spinlock during processing
the outstanding skbs).

I took over this patch from Eric Dumazet and tested it.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hannes Frederic Sowa authored and David S. Miller committed Apr 7, 2016
1 parent 8501786 commit 61881cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 6 additions & 1 deletion include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,12 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)

static inline void sock_release_ownership(struct sock *sk)
{
sk->sk_lock.owned = 0;
if (sk->sk_lock.owned) {
sk->sk_lock.owned = 0;

/* The sk_lock has mutex_unlock() semantics: */
mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
}
}

/*
Expand Down
5 changes: 0 additions & 5 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,11 +2483,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)
__release_sock(sk);
Expand Down

0 comments on commit 61881cf

Please sign in to comment.