diff options
author | Eric Dumazet <edumazet@google.com> | 2019-11-05 08:38:43 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-12 21:21:21 +0300 |
commit | 99ea48af7bd9366633b1887f8463027268254a56 (patch) | |
tree | a26f06be139476c1ed5768784e00152906a25f56 /include | |
parent | d32629dcd1e5de76185dbff8fb2b1f3f28a2aa52 (diff) | |
download | linux-99ea48af7bd9366633b1887f8463027268254a56.tar.xz |
net: prevent load/store tearing on sk->sk_stamp
[ Upstream commit f75359f3ac855940c5718af10ba089b8977bf339 ]
Add a couple of READ_ONCE() and WRITE_ONCE() to prevent
load-tearing and store-tearing in sock_read_timestamp()
and sock_write_timestamp()
This might prevent another KCSAN report.
Fixes: 3a0ed3e96197 ("sock: Make sock->sk_stamp thread-safe")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Acked-by: Deepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/sock.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 05e8faa84717..0252c0d00310 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2318,7 +2318,7 @@ static inline ktime_t sock_read_timestamp(struct sock *sk) return kt; #else - return sk->sk_stamp; + return READ_ONCE(sk->sk_stamp); #endif } @@ -2329,7 +2329,7 @@ static inline void sock_write_timestamp(struct sock *sk, ktime_t kt) sk->sk_stamp = kt; write_sequnlock(&sk->sk_stamp_seq); #else - sk->sk_stamp = kt; + WRITE_ONCE(sk->sk_stamp, kt); #endif } |