[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABeXuvqRoAYKn6vg7t7O6nA4BCEHjkMwYp9EvVGEEkFV_EonsA@mail.gmail.com>
Date: Tue, 5 Nov 2019 08:25:24 -0800
From: Deepa Dinamani <deepa.kernel@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Eric Dumazet <eric.dumazet@...il.com>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH net] net: prevent load/store tearing on sk->sk_stamp
On Mon, Nov 4, 2019 at 9:38 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> 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@...gle.com>
> Cc: Deepa Dinamani <deepa.kernel@...il.com>
> ---
> include/net/sock.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 8f9adcfac41bea7e46062851a25c042261323679..718e62fbe869db3ee7e8994bd1bfd559ab9c61c7 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2342,7 +2342,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
> }
>
> @@ -2353,7 +2353,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
> }
>
> --
> 2.24.0.rc1.363.gb1bccd3e3d-goog
I do not see any harm with this. Does it cause performance degradation?
Acked-by: Deepa Dinamani <deepa.kernel@...il.com>
-Deepa
Powered by blists - more mailing lists