mbox series

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

Message ID 20240604165241.44758-1-kuniyu@amazon.com (mailing list archive)
Headers show
Series af_unix: Fix lockless access of sk->sk_state and others fields. | expand

Message

Kuniyuki Iwashima June 4, 2024, 4:52 p.m. UTC
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/20240603143231.62085-1-kuniyu@amazon.com/


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(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 6, 2024, 11:10 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 4 Jun 2024 09:52:26 -0700 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [v2,net,01/15] af_unix: Set sk->sk_state under unix_state_lock() for truly disconencted peer.
    https://git.kernel.org/netdev/net/c/26bfb8b57063
  - [v2,net,02/15] af_unix: Annodate data-races around sk->sk_state for writers.
    https://git.kernel.org/netdev/net/c/942238f9735a
  - [v2,net,03/15] af_unix: Annotate data-race of sk->sk_state in unix_inq_len().
    https://git.kernel.org/netdev/net/c/3a0f38eb285c
  - [v2,net,04/15] af_unix: Annotate data-races around sk->sk_state in unix_write_space() and poll().
    https://git.kernel.org/netdev/net/c/eb0718fb3e97
  - [v2,net,05/15] af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().
    https://git.kernel.org/netdev/net/c/a9bf9c7dc6a5
  - [v2,net,06/15] af_unix: Annotate data-race of sk->sk_state in unix_accept().
    https://git.kernel.org/netdev/net/c/1b536948e805
  - [v2,net,07/15] af_unix: Annotate data-races around sk->sk_state in sendmsg() and recvmsg().
    https://git.kernel.org/netdev/net/c/8a34d4e8d974
  - [v2,net,08/15] af_unix: Annotate data-race of sk->sk_state in unix_stream_read_skb().
    https://git.kernel.org/netdev/net/c/af4c733b6b1a
  - [v2,net,09/15] af_unix: Annotate data-races around sk->sk_state in UNIX_DIAG.
    https://git.kernel.org/netdev/net/c/0aa3be7b3e1f
  - [v2,net,10/15] af_unix: Annotate data-races around sk->sk_sndbuf.
    https://git.kernel.org/netdev/net/c/b0632e53e0da
  - [v2,net,11/15] af_unix: Annotate data-race of net->unx.sysctl_max_dgram_qlen.
    https://git.kernel.org/netdev/net/c/bd9f2d05731f
  - [v2,net,12/15] af_unix: Use unix_recvq_full_lockless() in unix_stream_connect().
    https://git.kernel.org/netdev/net/c/45d872f0e655
  - [v2,net,13/15] af_unix: Use skb_queue_empty_lockless() in unix_release_sock().
    https://git.kernel.org/netdev/net/c/83690b82d228
  - [v2,net,14/15] af_unix: Use skb_queue_len_lockless() in sk_diag_show_rqlen().
    https://git.kernel.org/netdev/net/c/5d915e584d84
  - [v2,net,15/15] af_unix: Annotate data-race of sk->sk_shutdown in sk_diag_fill().
    https://git.kernel.org/netdev/net/c/efaf24e30ec3

You are awesome, thank you!