Received: by 10.213.65.68 with SMTP id h4csp1757627imn; Mon, 19 Mar 2018 12:26:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELtcN6GsT2pQD+4e+kR2JVIvClefHnCn5k2bIsu51+cVwfheieEgTcFW8ilKcp6oVTffhRli X-Received: by 10.101.88.4 with SMTP id g4mr9901118pgr.146.1521487563248; Mon, 19 Mar 2018 12:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487563; cv=none; d=google.com; s=arc-20160816; b=Wn8DD3SdxBymx8+3/PWDSufPTRm93xBE5cB7QTjPsF7D1rR5wKpMbdouH6DEujKTaO 4r/QjOTGeraZhyZRnFwL3OEwyeNAQBxvHv1D7heUs/SeYGKE+RLxiYRu1/EjrEGAZ9d5 FuNKSE2onKDa4BgS3l9Jct7MT5M4hG1QWZEIGRFeETC6BYdpn4qd9dIlHMRG/aTpcXy0 Xlkdd0iv78OsdYj1DqlrhBN1WBuhKacJtQuzAK50K6TpsVqmz/5cWScbXfoY51lU1CJB jY+8K5g/uKVaBinKAAuv+iJJUdeTHawoaPQ9ShYrbuxWqcSc43FlCe+U383T7A93Gb/2 Mc8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GzG44Y5TpcqWAppRUO8wpXrg/9TGF092F+zO+/bQYEg=; b=kvewbz1p71d6zC/tP/gnSAz+QikDC9lWf6lZuxp0ei2xwc2z2rG/8NfOtB3Q61cn5Q 5jFW11esaa1/hRiHoGo4LhA7vIjvzYSWPnbXaptCI4JPI/6EaaMTkok1PyzAS9/ucsXZ X/UP5Vwww/Qs7sa7DTzO8rvGk7Irt46ZtmAYHDBNKVKoqNGUjLCkZfVLK+SVrpeABE/m aqqDbBH9uqPtU0KXTDH7U3u3UviGawU6c/ghKrNyjC5woIpkzB4uVUUJ0LAoYT6BdKwC OYNQhzWSN6V8BkIWhiHGwGfXqkl9ddRuRcrT+tDelmhx18GcdTfclPeLEApnjWTqr74F 0cFw== ARC-Authentication-Results: i=1; mx.google.com; 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 d16-v6si484098pli.557.2018.03.19.12.25.47; Mon, 19 Mar 2018 12:26:03 -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; 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 S966106AbeCSTWv (ORCPT + 99 others); Mon, 19 Mar 2018 15:22:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50158 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031556AbeCSSYz (ORCPT ); Mon, 19 Mar 2018 14:24:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 83B5FFDA; Mon, 19 Mar 2018 18:24:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Scott , Jukka Rissanen , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.9 157/241] Bluetooth: 6lowpan: fix delay work init in add_peer_chan() Date: Mon, 19 Mar 2018 19:07:02 +0100 Message-Id: <20180319180757.671943434@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Scott [ Upstream commit d2891c4d071d807f01cc911dc42a68f4568d65cf ] When adding 6lowpan devices very rapidly we sometimes see a crash: [23122.306615] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.9.0-43-arm64 #1 Debian 4.9.9.linaro.43-1 [23122.315400] Hardware name: HiKey Development Board (DT) [23122.320623] task: ffff800075443080 task.stack: ffff800075484000 [23122.326551] PC is at expire_timers+0x70/0x150 [23122.330907] LR is at run_timer_softirq+0xa0/0x1a0 [23122.335616] pc : [] lr : [] pstate: 600001c5 This was due to add_peer_chan() unconditionally initializing the lowpan_btle_dev->notify_peers delayed work structure, even if the lowpan_btle_dev passed into add_peer_chan() had previously been initialized. Normally, this would go unnoticed as the delayed work timer is set for 100 msec, however when calling add_peer_chan() faster than 100 msec it clears out a previously queued delay work causing the crash above. To fix this, let add_peer_chan() know when a new lowpan_btle_dev is passed in so that it only performs the delay work initialization when needed. Signed-off-by: Michael Scott Acked-by: Jukka Rissanen Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/6lowpan.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -755,7 +755,8 @@ static void set_ip_addr_bits(u8 addr_typ } static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan, - struct lowpan_btle_dev *dev) + struct lowpan_btle_dev *dev, + bool new_netdev) { struct lowpan_peer *peer; @@ -786,7 +787,8 @@ static struct l2cap_chan *add_peer_chan( spin_unlock(&devices_lock); /* Notifying peers about us needs to be done without locks held */ - INIT_DELAYED_WORK(&dev->notify_peers, do_notify_peers); + if (new_netdev) + INIT_DELAYED_WORK(&dev->notify_peers, do_notify_peers); schedule_delayed_work(&dev->notify_peers, msecs_to_jiffies(100)); return peer->chan; @@ -843,6 +845,7 @@ out: static inline void chan_ready_cb(struct l2cap_chan *chan) { struct lowpan_btle_dev *dev; + bool new_netdev = false; dev = lookup_dev(chan->conn); @@ -853,12 +856,13 @@ static inline void chan_ready_cb(struct l2cap_chan_del(chan, -ENOENT); return; } + new_netdev = true; } if (!try_module_get(THIS_MODULE)) return; - add_peer_chan(chan, dev); + add_peer_chan(chan, dev, new_netdev); ifup(dev->netdev); }