lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 22 Dec 2018 14:29:22 +0100
From:   Arnd Bergmann <arnd@...db.de>
To:     Deepa Dinamani <deepa.kernel@...il.com>
Cc:     davem@...emloft.net, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, viro@...iv.linux.org.uk,
        y2038@...ts.linaro.org
Subject: Re: [PATCH] sock: Make sock->sk_tstamp thread-safe

On 12/21/18, Deepa Dinamani <deepa.kernel@...il.com> wrote:
> diff --git a/include/net/sock.h b/include/net/sock.h
> index fe58aec00d09..2cb641606533 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2311,8 +2313,11 @@ sock_recv_timestamp(struct msghdr *msg, struct sock
> *sk, struct sk_buff *skb)
>  	    (hwtstamps->hwtstamp &&
>  	     (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE)))
>  		__sock_recv_timestamp(msg, sk, skb);
> -	else
> +	else {
> +		write_seqlock(&sk->sk_stamp_seq);
>  		sk->sk_stamp = kt;
> +		write_sequnlock(&sk->sk_stamp_seq);
> +	}
>
>  	if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid)
>  		__sock_recv_wifi_status(msg, sk, skb);
> @@ -2332,10 +2337,15 @@ static inline void sock_recv_ts_and_drops(struct
> msghdr *msg, struct sock *sk,
>
>  	if (sk->sk_flags & FLAGS_TS_OR_DROPS || sk->sk_tsflags & TSFLAGS_ANY)
>  		__sock_recv_ts_and_drops(msg, sk, skb);
> -	else if (unlikely(sock_flag(sk, SOCK_TIMESTAMP)))
> +	else if (unlikely(sock_flag(sk, SOCK_TIMESTAMP))) {
> +		write_seqlock(&sk->sk_stamp_seq);
>  		sk->sk_stamp = skb->tstamp;
> -	else if (unlikely(sk->sk_stamp == SK_DEFAULT_STAMP))
> +		write_sequnlock(&sk->sk_stamp_seq);
> +	} else if (unlikely(sk->sk_stamp == SK_DEFAULT_STAMP)) {
> +		write_seqlock(&sk->sk_stamp_seq);
>  		sk->sk_stamp = 0;
> +		write_sequnlock(&sk->sk_stamp_seq);
> +	}
>  }
>

Hi Deepa,

Thanks a lot for the follow-up to our earlier discussion here!

Are we actually worried about concurrent writers here? I thought the
only problem was a race between writer and reader, which would mean
that we could solve it using only a seqcount_t which is cheaper to
update than a seqlock_t.

       Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ