Skip to content

Commit 251cd40

Browse files
edumazetdavem330
authored andcommitted
net: annotate data-races around sk->sk_bind_phc
sk->sk_bind_phc is read locklessly. Add corresponding annotations. Fixes: d463126 ("net: sock: extend SO_TIMESTAMPING for PHC binding") Signed-off-by: Eric Dumazet <[email protected]> Cc: Yangbo Lu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e3390b3 commit 251cd40

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

net/core/sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ static int sock_timestamping_bind_phc(struct sock *sk, int phc_index)
894894
if (!match)
895895
return -EINVAL;
896896

897-
sk->sk_bind_phc = phc_index;
897+
WRITE_ONCE(sk->sk_bind_phc, phc_index);
898898

899899
return 0;
900900
}
@@ -1720,7 +1720,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
17201720
case SO_TIMESTAMPING_OLD:
17211721
lv = sizeof(v.timestamping);
17221722
v.timestamping.flags = READ_ONCE(sk->sk_tsflags);
1723-
v.timestamping.bind_phc = sk->sk_bind_phc;
1723+
v.timestamping.bind_phc = READ_ONCE(sk->sk_bind_phc);
17241724
break;
17251725

17261726
case SO_RCVTIMEO_OLD:

net/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
939939

940940
if (tsflags & SOF_TIMESTAMPING_BIND_PHC)
941941
hwtstamp = ptp_convert_timestamp(&hwtstamp,
942-
sk->sk_bind_phc);
942+
READ_ONCE(sk->sk_bind_phc));
943943

944944
if (ktime_to_timespec64_cond(hwtstamp, tss.ts + 2)) {
945945
empty = 0;

0 commit comments

Comments
 (0)