sock: relax WARN_ON() in sock_owned_by_user()
authorEric Dumazet <edumazet@google.com>
Mon, 25 Apr 2016 13:34:09 +0000 (06:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Apr 2016 15:49:53 +0000 (11:49 -0400)
Valdis reported tons of stack dumps caused by WARN_ON() in
sock_owned_by_user()

This test needs to be relaxed if/when lockdep disables itself.

Note that other lockdep_sock_is_held() callers are all from
rcu_dereference_protected() sections which already are disabled
if/when lockdep has been disabled.

Fixes: fafc4e1ea1a4 ("sock: tigthen lockdep checks for sock_owned_by_user")
Reported-by: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h

index 52448baf19d7069c93770c21f0deb476d8f4b6a6..2fdb87f176cf57b853b2e2ebe197d3f47c9c9cf1 100644 (file)
@@ -1409,7 +1409,7 @@ static inline void unlock_sock_fast(struct sock *sk, bool slow)
 static inline bool sock_owned_by_user(const struct sock *sk)
 {
 #ifdef CONFIG_LOCKDEP
-       WARN_ON(!lockdep_sock_is_held(sk));
+       WARN_ON_ONCE(!lockdep_sock_is_held(sk) && debug_locks);
 #endif
        return sk->sk_lock.owned;
 }