Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6557634ybx; Mon, 11 Nov 2019 10:55:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxeOMq0XYCLingwxJiNg+UnKWV9y+9n5rV5UDNr+rJ6Vmx09FxE1opaFW6jWj8Z7o2cwDOi X-Received: by 2002:a05:6402:20c:: with SMTP id t12mr28060548edv.109.1573498530700; Mon, 11 Nov 2019 10:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498530; cv=none; d=google.com; s=arc-20160816; b=DwsFeTkshRZfnwJVYmcK4Rd+0nWMBDHNquB4/kZmN29Z+cQQecZxVfp2fI9xPNVL94 m/Jy8dpbaYcp2HiLUNKK/uGxXwTspX2lQFChS3wptqQrJVRlf2wt+jaRuob5Valua8aW GP79cte0Fd/egETAVsMrXraDQZZLFiyw7lPOOXSzrgK2fhtcx7Esz8dsMrN0SBP4uPpD PBufTdL2lwBk/rqGbKcp1tOMxaUdPsDEmtVm1taUHkD6eN+Xj/BDWd2lwd1ExIAcyCHp K8waylNBS9Ielt8hyORggmfWfAeaCAQmMh8jzVi9SAuEHH1ljqnXvha7qAnwrmvzkAWl QBRA== 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=4v3i6Os4FoiqiqMglnMizzsdnXvexyo58Fo4MqmhZeE=; b=Jtpexce4MsUpSNv7QLzdFJEPCKJTuWWCf6qqc3e7vWiYWJh28VwPt5/+jsaGalvkCr iSxfCqvMsKLDYLn4mVYCqCLRouKJTa73I2q+ajC24rhbm/YsESTQDGRi7/5xihcT0hTF 77/qhSQvV0IYWrDK7BcfMTQDkWkaKcHj92cM+qTHr2FZtVeuspE7L3+cdWTt16j61zD9 hiPPcfJmEd+1AAKVKg9/jVWWJ1SXLBFnBakmDV2Z+szGOKnuphS0b3GvnikD00EKZZZu KEt+Y9U/1UipSc0yMXZ3dFmBkgrY/LyH+x/bUhy61ljkjwkL7U1WMdAdKi6z1RyMqWlS IMZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AfDxTWfS; 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 a27si12099265edm.187.2019.11.11.10.55.07; Mon, 11 Nov 2019 10:55:30 -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=AfDxTWfS; 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 S1730075AbfKKSyg (ORCPT + 99 others); Mon, 11 Nov 2019 13:54:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:50616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729538AbfKKSyc (ORCPT ); Mon, 11 Nov 2019 13:54:32 -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 AA8E1222BD; Mon, 11 Nov 2019 18:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573498471; bh=MmuC3ntGipDDJDN5fDmYkcefGt/LDWxP73nABMNEhic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AfDxTWfSguO/z+2z+BFZesquxLTC6+OLp8TYqvnuj1SlfzHFEPrjiCJ0133fResNh snbvu4EngaRhinoj72ZAzkuGI6OgVmdEDuRgFaC0gC3jOvbeeOwaW/6vVCVb7ZcRZy up6NEtV3AInsQnHb/B2OOZtavDMOB72wVViNGAXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Simon Horman , Sasha Levin Subject: [PATCH 5.3 129/193] ipvs: move old_secure_tcp into struct netns_ipvs Date: Mon, 11 Nov 2019 19:28:31 +0100 Message-Id: <20191111181510.692053890@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181459.850623879@linuxfoundation.org> References: <20191111181459.850623879@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 c24b75e0f9239e78105f81c5f03a751641eb07ef ] syzbot reported the following issue : BUG: KCSAN: data-race in update_defense_level / update_defense_level read to 0xffffffff861a6260 of 4 bytes by task 3006 on cpu 1: update_defense_level+0x621/0xb30 net/netfilter/ipvs/ip_vs_ctl.c:177 defense_work_handler+0x3d/0xd0 net/netfilter/ipvs/ip_vs_ctl.c:225 process_one_work+0x3d4/0x890 kernel/workqueue.c:2269 worker_thread+0xa0/0x800 kernel/workqueue.c:2415 kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352 write to 0xffffffff861a6260 of 4 bytes by task 7333 on cpu 0: update_defense_level+0xa62/0xb30 net/netfilter/ipvs/ip_vs_ctl.c:205 defense_work_handler+0x3d/0xd0 net/netfilter/ipvs/ip_vs_ctl.c:225 process_one_work+0x3d4/0x890 kernel/workqueue.c:2269 worker_thread+0xa0/0x800 kernel/workqueue.c:2415 kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352 Reported by Kernel Concurrency Sanitizer on: CPU: 0 PID: 7333 Comm: kworker/0:5 Not tainted 5.4.0-rc3+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events defense_work_handler Indeed, old_secure_tcp is currently a static variable, while it needs to be a per netns variable. Fixes: a0840e2e165a ("IPVS: netns, ip_vs_ctl local vars moved to ipvs struct.") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: Simon Horman Signed-off-by: Sasha Levin --- include/net/ip_vs.h | 1 + net/netfilter/ipvs/ip_vs_ctl.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 3759167f91f56..078887c8c586a 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h @@ -889,6 +889,7 @@ struct netns_ipvs { struct delayed_work defense_work; /* Work handler */ int drop_rate; int drop_counter; + int old_secure_tcp; atomic_t dropentry; /* locks in ctl.c */ spinlock_t dropentry_lock; /* drop entry handling */ diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 248c76290116e..e29b00f514a0a 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -93,7 +93,6 @@ static bool __ip_vs_addr_is_local_v6(struct net *net, static void update_defense_level(struct netns_ipvs *ipvs) { struct sysinfo i; - static int old_secure_tcp = 0; int availmem; int nomem; int to_change = -1; @@ -174,35 +173,35 @@ static void update_defense_level(struct netns_ipvs *ipvs) spin_lock(&ipvs->securetcp_lock); switch (ipvs->sysctl_secure_tcp) { case 0: - if (old_secure_tcp >= 2) + if (ipvs->old_secure_tcp >= 2) to_change = 0; break; case 1: if (nomem) { - if (old_secure_tcp < 2) + if (ipvs->old_secure_tcp < 2) to_change = 1; ipvs->sysctl_secure_tcp = 2; } else { - if (old_secure_tcp >= 2) + if (ipvs->old_secure_tcp >= 2) to_change = 0; } break; case 2: if (nomem) { - if (old_secure_tcp < 2) + if (ipvs->old_secure_tcp < 2) to_change = 1; } else { - if (old_secure_tcp >= 2) + if (ipvs->old_secure_tcp >= 2) to_change = 0; ipvs->sysctl_secure_tcp = 1; } break; case 3: - if (old_secure_tcp < 2) + if (ipvs->old_secure_tcp < 2) to_change = 1; break; } - old_secure_tcp = ipvs->sysctl_secure_tcp; + ipvs->old_secure_tcp = ipvs->sysctl_secure_tcp; if (to_change >= 0) ip_vs_protocol_timeout_change(ipvs, ipvs->sysctl_secure_tcp > 1); -- 2.20.1