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:   Thu, 10 Oct 2019 11:59:29 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Eric Dumazet <edumazet@...gle.com>,
        "David S . Miller" <davem@...emloft.net>
Cc:     netdev <netdev@...r.kernel.org>,
        Eric Dumazet <eric.dumazet@...il.com>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>,
        Zhang Yu <zhangyu31@...du.com>, Wang Li <wangli39@...du.com>,
        Li RongQing <lirongqing@...du.com>
Subject: Re: [PATCH net] tun: remove possible false sharing in
 tun_flow_update()


On 2019/10/10 上午12:20, Eric Dumazet wrote:
> As mentioned in https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONCE#it-may-improve-performance
> a C compiler can legally transform
>
> if (e->queue_index != queue_index)
> 	e->queue_index = queue_index;
>
> to :
>
> 	e->queue_index = queue_index;
>
> Note that the code using jiffies has no issue, since jiffies
> has volatile attribute.
>
> if (e->updated != jiffies)
>      e->updated = jiffies;
>
> Fixes: 83b1bc122cab ("tun: align write-heavy flow entry members to a cache line")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Zhang Yu <zhangyu31@...du.com>
> Cc: Wang Li <wangli39@...du.com>
> Cc: Li RongQing <lirongqing@...du.com>
> Cc: Jason Wang <jasowang@...hat.com>
> ---
>   drivers/net/tun.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 812dc3a65efbb9d1ee2724e73978dbc4803ec171..a8d3141582a53caf407dc9aff61c452998de068f 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -526,8 +526,8 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
>   	e = tun_flow_find(head, rxhash);
>   	if (likely(e)) {
>   		/* TODO: keep queueing to old queue until it's empty? */
> -		if (e->queue_index != queue_index)
> -			e->queue_index = queue_index;
> +		if (READ_ONCE(e->queue_index) != queue_index)
> +			WRITE_ONCE(e->queue_index, queue_index);
>   		if (e->updated != jiffies)
>   			e->updated = jiffies;
>   		sock_rps_record_flow_hash(e->rps_rxhash);


Acked-by: Jason Wang <jasowang@...hat.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ