From: Eric Dumazet Date: Tue, 5 Nov 2019 05:38:43 +0000 (-0800) Subject: net: prevent load/store tearing on sk->sk_stamp X-Git-Tag: v4.9.201~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e8e9fd6a3a1c733ee9f0879fa4a3b2589406205;p=platform%2Fkernel%2Flinux-amlogic.git 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 Cc: Deepa Dinamani Acked-by: Deepa Dinamani Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/include/net/sock.h b/include/net/sock.h index 469c012a6d01..d8d14ae8892a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2142,7 +2142,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 } @@ -2153,7 +2153,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 }