Commit 99ea48af authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman

net: prevent load/store tearing on sk->sk_stamp

[ Upstream commit f75359f3 ]

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: 3a0ed3e9 ("sock: Make sock->sk_stamp thread-safe")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Acked-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent d32629dc
...@@ -2318,7 +2318,7 @@ static inline ktime_t sock_read_timestamp(struct sock *sk) ...@@ -2318,7 +2318,7 @@ static inline ktime_t sock_read_timestamp(struct sock *sk)
return kt; return kt;
#else #else
return sk->sk_stamp; return READ_ONCE(sk->sk_stamp);
#endif #endif
} }
...@@ -2329,7 +2329,7 @@ static inline void sock_write_timestamp(struct sock *sk, ktime_t kt) ...@@ -2329,7 +2329,7 @@ static inline void sock_write_timestamp(struct sock *sk, ktime_t kt)
sk->sk_stamp = kt; sk->sk_stamp = kt;
write_sequnlock(&sk->sk_stamp_seq); write_sequnlock(&sk->sk_stamp_seq);
#else #else
sk->sk_stamp = kt; WRITE_ONCE(sk->sk_stamp, kt);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment