Skip to content

af_unix: Fix lockless access of sk->sk_state and others fields.

Kuniyuki Iwashima netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest15 patches 15 repliesApplied 15/15
  2. v115 patches 2 repliesSuperseded

Changes in v2 from the cover letter

* Patch 1: Fix wrong double lock

Patches in v2 All 15 applied

#Subject and filesSizeRepliesApplied
1/15af_unix: Set sk->sk_state under unix_state_lock() for truly disconencted peer.net/unix/af_unix.c+8 -215 repliesApplied
2/15af_unix: Annodate data-races around sk->sk_state for writers.net/unix/af_unix.c+8 -60 repliesApplied
3/15af_unix: Annotate data-race of sk->sk_state in unix_inq_len().net/unix/af_unix.c+1 -10 repliesApplied
4/15af_unix: Annotate data-races around sk->sk_state in unix_write_space() and poll().net/unix/af_unix.c+12 -130 repliesApplied
5/15af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().net/unix/af_unix.c+2 -50 repliesApplied
6/15af_unix: Annotate data-race of sk->sk_state in unix_accept().net/unix/af_unix.c+1 -10 repliesApplied
7/15af_unix: Annotate data-races around sk->sk_state in sendmsg() and recvmsg().net/unix/af_unix.c+4 -40 repliesApplied
8/15af_unix: Annotate data-race of sk->sk_state in unix_stream_read_skb().net/unix/af_unix.c+1 -10 repliesApplied
9/15af_unix: Annotate data-races around sk->sk_state in UNIX_DIAG.net/unix/diag.c+4 -40 repliesApplied
10/15af_unix: Annotate data-races around sk->sk_sndbuf.net/unix/af_unix.c+3 -30 repliesApplied
11/15af_unix: Annotate data-race of net->unx.sysctl_max_dgram_qlen.net/unix/af_unix.c+1 -10 repliesApplied
12/15af_unix: Use unix_recvq_full_lockless() in unix_stream_connect().net/unix/af_unix.c+2 -80 repliesApplied
13/15af_unix: Use skb_queue_empty_lockless() in unix_release_sock().net/unix/af_unix.c+1 -10 repliesApplied
14/15af_unix: Use skb_queue_len_lockless() in sk_diag_show_rqlen().net/unix/diag.c+1 -10 repliesApplied
15/15af_unix: Annotate data-race of sk->sk_shutdown in sk_diag_fill().net/unix/diag.c+1 -10 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 net 00/15] af_unix: Fix lockless access of sk->sk_state and others fields.

The patch 1 fixes a bug where SOCK_DGRAM's sk->sk_state is changed to TCP_CLOSE even if the socket is connect()ed to another socket.

The rest of this series annotates lockless accesses to the following fields.

* sk->sk_state
* sk->sk_sndbuf
* net->unx.sysctl_max_dgram_qlen
* sk->sk_receive_queue.qlen
* sk->sk_shutdown

Note that with this series there is skb_queue_empty() left in unix_dgram_disconnected() that needs to be changed to lockless version, and unix_peer(other) access there should be protected by unix_state_lock().

This will require some refactoring, so another series will follow.

Changes:
v2:
* Patch 1: Fix wrong double lock

v1: https://lore.kernel.org/netdev/[email protected]/

Kuniyuki Iwashima (15):
af_unix: Set sk->sk_state under unix_state_lock() for truly
disconencted peer.
af_unix: Annodate data-races around sk->sk_state for writers.
af_unix: Annotate data-race of sk->sk_state in unix_inq_len().
af_unix: Annotate data-races around sk->sk_state in unix_write_space()

    and poll().
  af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().
  af_unix: Annotate data-race of sk->sk_state in unix_accept().
  af_unix: Annotate data-races around sk->sk_state in sendmsg() and
    recvmsg().

af_unix: Annotate data-race of sk->sk_state in unix_stream_read_skb().
af_unix: Annotate data-races around sk->sk_state in UNIX_DIAG.
af_unix: Annotate data-races around sk->sk_sndbuf.
af_unix: Annotate data-race of net->unx.sysctl_max_dgram_qlen.
af_unix: Use unix_recvq_full_lockless() in unix_stream_connect().
af_unix: Use skb_queue_empty_lockless() in unix_release_sock().
af_unix: Use skb_queue_len_lockless() in sk_diag_show_rqlen().
af_unix: Annotate data-race of sk->sk_shutdown in sk_diag_fill().

 net/unix/af_unix.c | 90 +++++++++++++++++++++++-----------------------
 net/unix/diag.c    | 12 +++----
 2 files changed, 50 insertions(+), 52 deletions(-)
Signature · 1 line
2.30.2