[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230831135212.2615985-6-edumazet@google.com>
Date: Thu, 31 Aug 2023 13:52:12 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, eric.dumazet@...il.com,
Eric Dumazet <edumazet@...gle.com>, Yangbo Lu <yangbo.lu@....com>
Subject: [PATCH net 5/5] net: annotate data-races around sk->sk_bind_phc
sk->sk_bind_phc is read locklessly. Add corresponding annotations.
Fixes: d463126e23f1 ("net: sock: extend SO_TIMESTAMPING for PHC binding")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Cc: Yangbo Lu <yangbo.lu@....com>
---
net/core/sock.c | 4 ++--
net/socket.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index d05a290300b6c8c765d6733520c50978f35f2dd0..d3c7b53368d2245c8c2299a5f8ad79fad4de4d16 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -894,7 +894,7 @@ static int sock_timestamping_bind_phc(struct sock *sk, int phc_index)
if (!match)
return -EINVAL;
- sk->sk_bind_phc = phc_index;
+ WRITE_ONCE(sk->sk_bind_phc, phc_index);
return 0;
}
@@ -1720,7 +1720,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
case SO_TIMESTAMPING_OLD:
lv = sizeof(v.timestamping);
v.timestamping.flags = READ_ONCE(sk->sk_tsflags);
- v.timestamping.bind_phc = sk->sk_bind_phc;
+ v.timestamping.bind_phc = READ_ONCE(sk->sk_bind_phc);
break;
case SO_RCVTIMEO_OLD:
diff --git a/net/socket.c b/net/socket.c
index 98ffffab949e850fe07904f1cf20ff2ce4a9b5d1..928b05811cfd3333ffc101f850486bc1e8e3f611 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -939,7 +939,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
if (tsflags & SOF_TIMESTAMPING_BIND_PHC)
hwtstamp = ptp_convert_timestamp(&hwtstamp,
- sk->sk_bind_phc);
+ READ_ONCE(sk->sk_bind_phc));
if (ktime_to_timespec64_cond(hwtstamp, tss.ts + 2)) {
empty = 0;
--
2.42.0.rc2.253.gd59a3bf2b4-goog
Powered by blists - more mailing lists