Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp577724img; Fri, 22 Mar 2019 04:25:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw0/zamV9CjPZi12GnFlIWzMfCGD1z9GBetiI3CtWq7DogiHkG0850Q0OSuxapNThG2hHg X-Received: by 2002:a17:902:1123:: with SMTP id d32mr8802493pla.16.1553253900017; Fri, 22 Mar 2019 04:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253900; cv=none; d=google.com; s=arc-20160816; b=H1kjy31L6XNK6irf3tyUkIFibc+i0eomHERzBYJIrGOEOnALdXOfrypP565QYx0uZB sOwzDfcU3O18bWrH5YLxgYXPkWJCMSGDGQ+hFcmUZ7JG5qcCtE0uiPsgneQu/ZBr/Rbw DpOMvIb1zmq1kinNdorQhEIJDkTnM3KjO1+LN1zFeq2/IPdWhHx3Abxeow9IkcUbqjuM JfGWIhHeN0uBEWx6/1ZM3BJRDJ/qg1qV83dwlNy6y6BfuCG2NqavFMLB2+ccl6JiOZOd FnET8rDG9h7dQKufnHGE9SEAStCiOpv2MZx2HG+CPjuiy7wPWc+l297bK3a4uTFlw27a uFVQ== 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=dw4+Gzsl6G1U/GWPl07gMG5gpe+FykdMcn6jk3mORYM=; b=zZNSq4YRFrr1yBGvhna15zFs5NZzGQafIX3ziXp3BKFXSQfGvIgKLz3dNvsDXvlgp1 4TOh2R2p8ADexwjR1GJEN1i04Oxb08x4HbIHGQ9xDpI0MoBZaXlDSbi6T8wmoKI3xtNM wjL9bnIO9raoGIuke3r1u9ie/k4Hk1+YzHEt9+SIaJhzw0inqQIxKNpodfog5AXE/HAt AoiId0ygQNJCorU8YJDuCGxJ1fCjzpZnRy4TCLcIHDO69x8JJgkj+DrEvvBUThifC4G7 vbMuKgKuN4hq++fBPZtCXRe01QmAUG+myZitoHXKDh4d9W1PFw46ZqB24BZnARj0m4MJ ixBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1bS53EbN; 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 d12si5862952pgj.416.2019.03.22.04.24.45; Fri, 22 Mar 2019 04:25:00 -0700 (PDT) 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=1bS53EbN; 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 S1728734AbfCVLWH (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbfCVLWF (ORCPT ); Fri, 22 Mar 2019 07:22:05 -0400 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 DE29D218D4; Fri, 22 Mar 2019 11:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253724; bh=nArcBDAObDWHljuvowDkWYuDGh0OPyCfYk/aXJvzITE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bS53EbN7WxmOEwG69WlWeOFfshxcEBKBM+pwGF07JKIH0vypLJAlJInmCmTdyVDG Oq2RWSyltiQINMHmDRwjIPar0uKMW5i5WJnyopVmRHBebHxIm1TeVyec7sgP+FXr0e G5pZJK7fVL8MXggqbHiyH6MmyDGNHoCOKQ14QpB0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Amit Cohen , "David S. Miller" Subject: [PATCH 3.18 052/134] ip6mr: Do not call __IP6_INC_STATS() from preemptible context Date: Fri, 22 Mar 2019 12:14:25 +0100 Message-Id: <20190322111213.717253039@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ido Schimmel [ Upstream commit 87c11f1ddbbad38ad8bad47af133a8208985fbdf ] Similar to commit 44f49dd8b5a6 ("ipmr: fix possible race resulting from improper usage of IP_INC_STATS_BH() in preemptible context."), we cannot assume preemption is disabled when incrementing the counter and accessing a per-CPU variable. Preemption can be enabled when we add a route in process context that corresponds to packets stored in the unresolved queue, which are then forwarded using this route [1]. Fix this by using IP6_INC_STATS() which takes care of disabling preemption on architectures where it is needed. [1] [ 157.451447] BUG: using __this_cpu_add() in preemptible [00000000] code: smcrouted/2314 [ 157.460409] caller is ip6mr_forward2+0x73e/0x10e0 [ 157.460434] CPU: 3 PID: 2314 Comm: smcrouted Not tainted 5.0.0-rc7-custom-03635-g22f2712113f1 #1336 [ 157.460449] Hardware name: Mellanox Technologies Ltd. MSN2100-CB2FO/SA001017, BIOS 5.6.5 06/07/2016 [ 157.460461] Call Trace: [ 157.460486] dump_stack+0xf9/0x1be [ 157.460553] check_preemption_disabled+0x1d6/0x200 [ 157.460576] ip6mr_forward2+0x73e/0x10e0 [ 157.460705] ip6_mr_forward+0x9a0/0x1510 [ 157.460771] ip6mr_mfc_add+0x16b3/0x1e00 [ 157.461155] ip6_mroute_setsockopt+0x3cb/0x13c0 [ 157.461384] do_ipv6_setsockopt.isra.8+0x348/0x4060 [ 157.462013] ipv6_setsockopt+0x90/0x110 [ 157.462036] rawv6_setsockopt+0x4a/0x120 [ 157.462058] __sys_setsockopt+0x16b/0x340 [ 157.462198] __x64_sys_setsockopt+0xbf/0x160 [ 157.462220] do_syscall_64+0x14d/0x610 [ 157.462349] entry_SYSCALL_64_after_hwframe+0x49/0xbe Fixes: 0912ea38de61 ("[IPV6] MROUTE: Add stats in multicast routing module method ip6_mr_forward().") Signed-off-by: Ido Schimmel Reported-by: Amit Cohen Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6mr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1987,10 +1987,10 @@ int ip6mr_compat_ioctl(struct sock *sk, static inline int ip6mr_forward2_finish(struct sk_buff *skb) { - IP6_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), - IPSTATS_MIB_OUTFORWDATAGRAMS); - IP6_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), - IPSTATS_MIB_OUTOCTETS, skb->len); + IP6_INC_STATS(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), + IPSTATS_MIB_OUTFORWDATAGRAMS); + IP6_ADD_STATS(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), + IPSTATS_MIB_OUTOCTETS, skb->len); return dst_output(skb); }