Skip to content

Commit 61881cf

Browse files
strssndktndavem330
authored andcommitted
sock: fix lockdep annotation in release_sock
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 <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8501786 commit 61881cf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

include/net/sock.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,12 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
13331333

13341334
static inline void sock_release_ownership(struct sock *sk)
13351335
{
1336-
sk->sk_lock.owned = 0;
1336+
if (sk->sk_lock.owned) {
1337+
sk->sk_lock.owned = 0;
1338+
1339+
/* The sk_lock has mutex_unlock() semantics: */
1340+
mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
1341+
}
13371342
}
13381343

13391344
/*

net/core/sock.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,11 +2483,6 @@ EXPORT_SYMBOL(lock_sock_nested);
24832483

24842484
void release_sock(struct sock *sk)
24852485
{
2486-
/*
2487-
* The sk_lock has mutex_unlock() semantics:
2488-
*/
2489-
mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
2490-
24912486
spin_lock_bh(&sk->sk_lock.slock);
24922487
if (sk->sk_backlog.tail)
24932488
__release_sock(sk);

0 commit comments

Comments
 (0)