Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6571517ybx; Mon, 11 Nov 2019 11:08:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzOYdvDo+R1LRj2vmryjMgMvYNi5V6KyItS1fWHjZQUFTXY71Jq7uUn9gMK7Kqduau4b/j9 X-Received: by 2002:a05:6402:329:: with SMTP id q9mr13269506edw.76.1573499311105; Mon, 11 Nov 2019 11:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573499311; cv=none; d=google.com; s=arc-20160816; b=u3WhYf5POvHTp1wMXwBLNhzUjAeVUjkdQmDRpVQglPBMKvulTfTd/hzOWwz7d9HwZV Cdq3o+ePNnrrjh/a83kombL6SznuaB+tJdVhhVyvpKXXcP77sLN3HsH1NnS0jpk0nJyP B94JNb1NarQa+xZq6F0k50ucT3CxaSMc9VEAn7/WBknuwKce7LAglejhNAe8qICljLV2 /auEZE469lqnGewGJmgYvqgEPwzElpj3m8JiLfaWm7TG7G0NispM1r42qVa1jRhS6thm jPhWDC0lfjZKbtRo4xGu34nJJlSpYA6UT0lGuXbWmFdkX44cym1+gBzgFgI0mYho+NF+ fDlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/LfgnOLJfrO/iYQzMrRLktX1DURrWEcwg/A8u4S5RNw=; b=gvfbIbJng622ZTOWHJirs1v8LoibyVrDsYex2ZkI0dAVTcj6PoWhW2g6llfn5j5S3I RKSNGnJR0/B3jGKaB0JlimHJPzsZvbNABEQ+l4SxeWihEZmzOShJ5Nwc8IonYBSEbSpx wQAeM9BB2M10oj0eJpNCnei8BJ5f4Rf1KbReVnQRXdK8W58WWIZzT6nEfXBKzVR0bqoh ZQ0izj4Xvcr+GkdoA8+W5xSNW1CLVCxjtEVga6U5JzC7UIu6MZDfxRI36U0Ko3vc2GCs zdFYIVM02nZ9mbSyKQFlfJIg6uFI8NlEifuObtaypxS0BpkKi4odrZ+Kydqcl1UqycCY rfpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MYdV86m5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y17si3126122ejc.360.2019.11.11.11.08.05; Mon, 11 Nov 2019 11:08:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MYdV86m5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728732AbfKKSmE (ORCPT + 99 others); Mon, 11 Nov 2019 13:42:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:33140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728404AbfKKSmA (ORCPT ); Mon, 11 Nov 2019 13:42:00 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D66102067B; Mon, 11 Nov 2019 18:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497719; bh=aLm2FQjWYpVfY++zTL+4IoRhYtP2eFTwLfae6oERYEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MYdV86m5/K71BIoHiuydLO3q8VUECCi/3qFkcviy2TNEhlCajJeM3JpYNjNxtWopo yDfXFhiJgmCI+pKS1hq+ANGEc4a4yjdtke34KQRN92q5DxzJ+yv6Kuf3TCf+5qaVve tLqpB2Lc0nNOuZb+SX4Ynl47AB5MtTK3T1dNtDmg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.19 005/125] net: fix data-race in neigh_event_send() Date: Mon, 11 Nov 2019 19:27:24 +0100 Message-Id: <20191111181440.049305471@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 1b53d64435d56902fc234ff2507142d971a09687 ] KCSAN reported the following data-race [1] The fix will also prevent the compiler from optimizing out the condition. [1] BUG: KCSAN: data-race in neigh_resolve_output / neigh_resolve_output write to 0xffff8880a41dba78 of 8 bytes by interrupt on cpu 1: neigh_event_send include/net/neighbour.h:443 [inline] neigh_resolve_output+0x78/0x480 net/core/neighbour.c:1474 neigh_output include/net/neighbour.h:511 [inline] ip_finish_output2+0x4af/0xe40 net/ipv4/ip_output.c:228 __ip_finish_output net/ipv4/ip_output.c:308 [inline] __ip_finish_output+0x23a/0x490 net/ipv4/ip_output.c:290 ip_finish_output+0x41/0x160 net/ipv4/ip_output.c:318 NF_HOOK_COND include/linux/netfilter.h:294 [inline] ip_output+0xdf/0x210 net/ipv4/ip_output.c:432 dst_output include/net/dst.h:436 [inline] ip_local_out+0x74/0x90 net/ipv4/ip_output.c:125 __ip_queue_xmit+0x3a8/0xa40 net/ipv4/ip_output.c:532 ip_queue_xmit+0x45/0x60 include/net/ip.h:237 __tcp_transmit_skb+0xe81/0x1d60 net/ipv4/tcp_output.c:1169 tcp_transmit_skb net/ipv4/tcp_output.c:1185 [inline] __tcp_retransmit_skb+0x4bd/0x15f0 net/ipv4/tcp_output.c:2976 tcp_retransmit_skb+0x36/0x1a0 net/ipv4/tcp_output.c:2999 tcp_retransmit_timer+0x719/0x16d0 net/ipv4/tcp_timer.c:515 tcp_write_timer_handler+0x42d/0x510 net/ipv4/tcp_timer.c:598 tcp_write_timer+0xd1/0xf0 net/ipv4/tcp_timer.c:618 read to 0xffff8880a41dba78 of 8 bytes by interrupt on cpu 0: neigh_event_send include/net/neighbour.h:442 [inline] neigh_resolve_output+0x57/0x480 net/core/neighbour.c:1474 neigh_output include/net/neighbour.h:511 [inline] ip_finish_output2+0x4af/0xe40 net/ipv4/ip_output.c:228 __ip_finish_output net/ipv4/ip_output.c:308 [inline] __ip_finish_output+0x23a/0x490 net/ipv4/ip_output.c:290 ip_finish_output+0x41/0x160 net/ipv4/ip_output.c:318 NF_HOOK_COND include/linux/netfilter.h:294 [inline] ip_output+0xdf/0x210 net/ipv4/ip_output.c:432 dst_output include/net/dst.h:436 [inline] ip_local_out+0x74/0x90 net/ipv4/ip_output.c:125 __ip_queue_xmit+0x3a8/0xa40 net/ipv4/ip_output.c:532 ip_queue_xmit+0x45/0x60 include/net/ip.h:237 __tcp_transmit_skb+0xe81/0x1d60 net/ipv4/tcp_output.c:1169 tcp_transmit_skb net/ipv4/tcp_output.c:1185 [inline] __tcp_retransmit_skb+0x4bd/0x15f0 net/ipv4/tcp_output.c:2976 tcp_retransmit_skb+0x36/0x1a0 net/ipv4/tcp_output.c:2999 tcp_retransmit_timer+0x719/0x16d0 net/ipv4/tcp_timer.c:515 tcp_write_timer_handler+0x42d/0x510 net/ipv4/tcp_timer.c:598 Reported by Kernel Concurrency Sanitizer on: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/neighbour.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -430,8 +430,8 @@ static inline int neigh_event_send(struc { unsigned long now = jiffies; - if (neigh->used != now) - neigh->used = now; + if (READ_ONCE(neigh->used) != now) + WRITE_ONCE(neigh->used, now); if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) return __neigh_event_send(neigh, skb); return 0;