From patchwork Tue Jul 25 20:45:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 108697 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp28654qge; Tue, 25 Jul 2017 13:45:38 -0700 (PDT) X-Received: by 10.84.177.131 with SMTP id x3mr6366258plb.280.1501015538069; Tue, 25 Jul 2017 13:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501015538; cv=none; d=google.com; s=arc-20160816; b=rXSifDkgqyU1i2ltcdNXTQLKy+jLAdGCWLGMtPIzr6UNsjMXcABBFMhPOdHRz6sJod 6tl5C0Cl1UgIqqLDKCBfQqYSTuPin/OpXgSKi91JmYdePsbRjAagK9tvKm0dxXHRfehJ 0ffihTEo+nCK//0sFU7/+TiDEiSuR77wGHm80Rzf7xcWSngbxWb7QKnh9x/x7OxYev2D XAAXn0qoq5wmR+3SZSf723468WX96nCoIWQQV79jGQ+Wl69t0zVJMtl2U5ycUt5vc7uy pjDmhimH6n3tljfSNjpSbi1wTQ3t3bADDOQ0mIE8+rNo5Dof8JAIBAKiIq7cXHQ5gxie +abg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=HLN6Q4zRc5ANZ1niCFosNxd1Edpd7dY+6wLC5x1oqL4=; b=J9oSZ2fbBYHo8j45gWatM2b39u7KDdTCrdwRacDrHiEJ/VeXS8+UHKC+QN08kkPzw5 qHpS8jCDPzyNgdB6lqdkXidnIFiXJYDkxjPdig8UDR94mfrb8qGFHOXi+tb9Ecvyhy9f EqT+eKQbN6ZvQbzBJhMOTPLo7qwacl4VUnF/I16vU6lT8pByn01P/ITk9Q1LCsu3xCEV 6h7KmrsscyBRjxIHagPxI92TOOrPGfSmEvT4P8yLjKSM51TAV0a2eNTyaFPmTwkqiemp AUjPG2kXKGmOWknj+tdwQDesHQyuvJTVmvq2STJDhyHS300yklVeBLhp0XpCVaEmpJeQ fPZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=akE52Aqj; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p127si4045682pfg.452.2017.07.25.13.45.37; Tue, 25 Jul 2017 13:45:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.b=akE52Aqj; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752558AbdGYUpg (ORCPT + 6 others); Tue, 25 Jul 2017 16:45:36 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:37260 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752049AbdGYUpe (ORCPT ); Tue, 25 Jul 2017 16:45:34 -0400 Received: by mail-pg0-f48.google.com with SMTP id y129so74739160pgy.4 for ; Tue, 25 Jul 2017 13:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HLN6Q4zRc5ANZ1niCFosNxd1Edpd7dY+6wLC5x1oqL4=; b=akE52AqjTCWUstWJGkwCcxYF785cP4LJENXsf/LoPAne1gtgtXLqEiuUKF2YV0S8Yi 05dR64d90AzI4qAbB8jWw3zY1aBCnyLMTve+xKQzrc0D7QhnQGzCv9SKBgQwx4kY0UYp 9zMWgT+Dn3InV9nLfGmNtLfWdVgimV/4ogm88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HLN6Q4zRc5ANZ1niCFosNxd1Edpd7dY+6wLC5x1oqL4=; b=Dy0RSfNfXQifCuiYmjiCfveHn5VQtbDUBTAxtbNRe+9O0BFQLSZDiBOLdNwsYmvyZl e0yhbsI+fmPDTW7vPIeStPWwzu3MsOUeQJvzFaVQiwKWVj6YwXonnt4pI10tzSW18dDu /DSqdWA4TbfIk/HBpRR6Fe5ooCVHdiOy64ZJns7XApoK92K0ikSmAjhVRVUm11gyfJ+O XiDiF6vuPSmwbxm8XLUYs5nKLEZNLPs6sWFT2lSfhPGFoAH/xUNgxYFGJ8SsFcFclQhF BNiArHjvT8ptrcV5xpkFaaUgHA+mhMD7QRRokJ/2cbBgEO5oRhIY+Lwcx5yq/FG3Ivml ZN/g== X-Gm-Message-State: AIVw112BVr3o0szL7OFyqHsdQDt3m3iuDVmo7h5Nrsc5bbqvp8KpmMiO +uHh+7Ywx2EvodLYudo1aA== X-Received: by 10.98.86.154 with SMTP id h26mr12494681pfj.250.1501015534180; Tue, 25 Jul 2017 13:45:34 -0700 (PDT) Received: from localhost.localdomain ([106.51.135.235]) by smtp.gmail.com with ESMTPSA id d4sm532125pfj.59.2017.07.25.13.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 13:45:33 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Jan Stancek , "David S . Miller" Subject: [PATCH for-3.18 01/15] ipv6: fix possible deadlock in ip6_fl_purge / ip6_fl_gc Date: Wed, 26 Jul 2017 02:15:12 +0530 Message-Id: <1501015526-32178-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501015526-32178-1-git-send-email-amit.pundir@linaro.org> References: <1501015526-32178-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Stancek commit 4762fb980465463734f02c67c67f40beb8903f73 upstream. Use spin_lock_bh in ip6_fl_purge() to prevent following potentially deadlock scenario between ip6_fl_purge() and ip6_fl_gc() timer. ================================= [ INFO: inconsistent lock state ] 3.19.0 #1 Not tainted --------------------------------- inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. swapper/5/0 [HC0[0]:SC1[1]:HE1:SE0] takes: (ip6_fl_lock){+.?...}, at: [] ip6_fl_gc+0x2d/0x180 {SOFTIRQ-ON-W} state was registered at: [] __lock_acquire+0x4a0/0x10b0 [] lock_acquire+0xc4/0x2b0 [] _raw_spin_lock+0x3d/0x80 [] ip6_flowlabel_net_exit+0x28/0x110 [] ops_exit_list.isra.1+0x39/0x60 [] cleanup_net+0x100/0x1e0 [] process_one_work+0x20a/0x830 [] worker_thread+0x11b/0x460 [] kthread+0x104/0x120 [] ret_from_fork+0x7c/0xb0 irq event stamp: 84640 hardirqs last enabled at (84640): [] _raw_spin_unlock_irq+0x30/0x50 hardirqs last disabled at (84639): [] _raw_spin_lock_irq+0x1f/0x80 softirqs last enabled at (84628): [] _local_bh_enable+0x21/0x50 softirqs last disabled at (84629): [] irq_exit+0x12d/0x150 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(ip6_fl_lock); lock(ip6_fl_lock); *** DEADLOCK *** Signed-off-by: Jan Stancek Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- net/ipv6/ip6_flowlabel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 3dd7d4ebd7cd..a837f2065d2a 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -172,7 +172,7 @@ static void __net_exit ip6_fl_purge(struct net *net) { int i; - spin_lock(&ip6_fl_lock); + spin_lock_bh(&ip6_fl_lock); for (i = 0; i <= FL_HASH_MASK; i++) { struct ip6_flowlabel *fl; struct ip6_flowlabel __rcu **flp; @@ -190,7 +190,7 @@ static void __net_exit ip6_fl_purge(struct net *net) flp = &fl->next; } } - spin_unlock(&ip6_fl_lock); + spin_unlock_bh(&ip6_fl_lock); } static struct ip6_flowlabel *fl_intern(struct net *net,