mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 23:25:07 +00:00
net: prevent load/store tearing on sk->sk_stamp
[ Upstream commitf75359f3ac
] 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:3a0ed3e961
("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>
This commit is contained in:
parent
d32629dcd1
commit
99ea48af7b
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue