diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2024-06-20 13:56:18 -0700 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-06-25 11:10:18 +0200 |
commit | c4da4661d985fd3cbaea3ea6101e2dd0d2ad4b74 (patch) | |
tree | 0a66ad0e3deebd7050b4418652d9ecff683ed6ce /net/unix | |
parent | b380b18102a0b72a9726077474a2915dfe8bbc08 (diff) |
af_unix: Remove U_LOCK_DIAG.
sk_diag_dump_icons() acquires embryo's lock by unix_state_lock_nested()
to fetch its peer.
The embryo's ->peer is set to NULL only when its parent listener is
close()d. Then, unix_release_sock() is called for each embryo after
unlinking skb by skb_dequeue().
In sk_diag_dump_icons(), we hold the parent's recvq lock, so we need
not acquire unix_state_lock_nested(), and peer is always non-NULL.
Let's remove unnecessary unix_state_lock_nested() and non-NULL test
for peer.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/diag.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c index d2d66727b0da..9138af8b465e 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -73,20 +73,9 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb) buf = nla_data(attr); i = 0; - skb_queue_walk(&sk->sk_receive_queue, skb) { - struct sock *req, *peer; - - req = skb->sk; - /* - * The state lock is outer for the same sk's - * queue lock. With the other's queue locked it's - * OK to lock the state. - */ - unix_state_lock_nested(req, U_LOCK_DIAG); - peer = unix_sk(req)->peer; - buf[i++] = (peer ? sock_i_ino(peer) : 0); - unix_state_unlock(req); - } + skb_queue_walk(&sk->sk_receive_queue, skb) + buf[i++] = sock_i_ino(unix_peer(skb->sk)); + spin_unlock(&sk->sk_receive_queue.lock); } |