From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net 4/4] af_unix: Fix data race around sk->sk_err.
Date: Fri, 1 Sep 2023 17:27:08 -0700 [thread overview]
Message-ID: <20230902002708.91816-5-kuniyu@amazon.com> (raw)
In-Reply-To: <20230902002708.91816-1-kuniyu@amazon.com>
As with sk->sk_shutdown shown in the previous patch, sk->sk_err can be
read locklessly by unix_dgram_sendmsg().
Let's use READ_ONCE() for sk_err as well.
Note that the writer side is marked by commit cc04410af7de ("af_unix:
annotate lockless accesses to sk->sk_err").
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/core/sock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index e3da7eae9338..16584e2dd648 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2749,7 +2749,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
break;
if (READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN)
break;
- if (sk->sk_err)
+ if (READ_ONCE(sk->sk_err))
break;
timeo = schedule_timeout(timeo);
}
--
2.30.2
next prev parent reply other threads:[~2023-09-02 0:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-02 0:27 [PATCH v1 net 0/4] af_unix: Fix four data-races Kuniyuki Iwashima
2023-09-02 0:27 ` [PATCH v1 net 1/4] af_unix: Fix data-races around user->unix_inflight Kuniyuki Iwashima
2023-09-02 5:45 ` Willy Tarreau
2023-09-02 6:39 ` Eric Dumazet
2023-09-02 0:27 ` [PATCH v1 net 2/4] af_unix: Fix data-race around unix_tot_inflight Kuniyuki Iwashima
2023-09-02 6:41 ` Eric Dumazet
2023-09-02 0:27 ` [PATCH v1 net 3/4] af_unix: Fix data-races around sk->sk_shutdown Kuniyuki Iwashima
2023-09-02 6:43 ` Eric Dumazet
2023-09-02 0:27 ` Kuniyuki Iwashima [this message]
2023-09-02 6:45 ` [PATCH v1 net 4/4] af_unix: Fix data race around sk->sk_err Eric Dumazet
2023-09-04 10:12 ` [PATCH v1 net 0/4] af_unix: Fix four data-races patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230902002708.91816-5-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.