Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2571457imu; Thu, 29 Nov 2018 07:04:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/XsUCCcCM3ePcHXZev3ZH64HFuBeSesb6AZKA1Vx5grH4MqfWyoCEkUIfXdX6xXWSX2hDz1 X-Received: by 2002:a62:db41:: with SMTP id f62mr1732631pfg.123.1543503872607; Thu, 29 Nov 2018 07:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503872; cv=none; d=google.com; s=arc-20160816; b=DITMoBL9szZJIEVv5a7wLwjoyvxDq1B3oF8X+VMcXTbsIXftepS9yDhTTarAqrAPD0 FVnEa9BO9Sfh5+JjnDBJ0X5+cm7v2x7kOn6KxBEvtMttpLMA0whaLPTCNMomlOSHTuNO hFSfOWLewgFpTJcykaqy5WRu/wYVivSYJ/C+i3YYf90nCf34DZtJG2ZUx3S/XmnjfBlP 7rCy2bYd6yJjQqdpq1nwX+X3wYqaRpw+hwWxRlhEf+/5wbHI3iEgiCeqW/PfC2GGode0 5cCdImAK/FkEBCLPwwHdKTc5m398Ashpo0OmfplDXlmZmUfaDmTY6b0yXjubW8A4kNkj YzJg== 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=3Typ1/iiIL6KL9gvo5DT0RLCAW+GRklPZMMrbI7jr5M=; b=vmgnJgTGbesxfOzuWMqkBaZ86Lkka+SqZPVKUZMu9RTSvp9FiAgzO5KaXQZdvjgHYE Myrs1N/4YdnmPO/Cc12gUQfz9poj7nm2BjqzVSfoi5mxVu2QveuN2yUQWEtPX2/qlBef T3QFlaezH47oOp9DbG65L6c7T1JvhcASEvtRAIrW3k+OV63Kzh8y0EXdbVWlt80mC8JU eWm3+N2Yx377iAsryDLB/FxG8q9Swq6Eki3Ft2rp7wOnbgvu9rK/XkMtKND0MhCfXYAl wBi1SlNhnI3IXDHzcTWm8abWfOuf5Ly4cIpqPXnPvxcEa/CPhHHkyPpsSgHdmBzbIKyl hFzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H4+m49CJ; 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 q24si2536765pls.325.2018.11.29.07.03.55; Thu, 29 Nov 2018 07:04:32 -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=H4+m49CJ; 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 S1730612AbeK3BX3 (ORCPT + 99 others); Thu, 29 Nov 2018 20:23:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:45594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729819AbeK3BXZ (ORCPT ); Thu, 29 Nov 2018 20:23:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 9DC3621104; Thu, 29 Nov 2018 14:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501075; bh=ijSgJKeW7egNWCmSTYmc1r1pT8rwJOss3eDp8okAkrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4+m49CJOrGswnXlaaD82+HolwNPV6gCy/EJiasMSDMup2x24+1al7vTrlWKzSzfM IqiTWqllXJJg4bhBMSA+3KuyOcTdxb78cK/XjEP9fverhAVcjlvzMzKKAc2entW0dH PJJe3mv++4Exes9Rw6vO+afbJJGdywxpwYR7sFEs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasanthakumar Thiagarajan , Kalle Valo , Amit Pundir Subject: [PATCH 4.4 31/86] ath10k: fix kernel panic due to race in accessing arvif list Date: Thu, 29 Nov 2018 15:11:56 +0100 Message-Id: <20181129140112.636127833@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasanthakumar Thiagarajan commit ebaa4b1620bf69f2bc43cb45ea85fbafdaec23c3 upstream. arvifs list is traversed within data_lock spin_lock in tasklet context to fill channel information from the corresponding vif. This means any access to arvifs list for add/del operations should also be protected with the same spin_lock to avoid the race. Fix this by performing list add/del on arvfis within the data_lock. This could fix kernel panic something like the below. LR is at ath10k_htt_rx_pktlog_completion_handler+0x100/0xb6c [ath10k_core] PC is at ath10k_htt_rx_pktlog_completion_handler+0x1c0/0xb6c [ath10k_core] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [] (ath10k_htt_rx_pktlog_completion_handler+0x2f4/0xb6c [ath10k_core]) [] (ath10k_htt_txrx_compl_task+0x8b4/0x1188 [ath10k_core]) [] (tasklet_action+0x8c/0xec) [] (__do_softirq+0xdc/0x208) [] (irq_exit+0x84/0xe0) [] (__handle_domain_irq+0x80/0xa0) [] (gic_handle_irq+0x38/0x5c) [] (__irq_svc+0x40/0x74) (gdb) list *(ath10k_htt_rx_pktlog_completion_handler+0x1c0) 0x136c0 is in ath10k_htt_rx_h_channel (drivers/net/wireless/ath/ath10k/htt_rx.c:769) 764 struct cfg80211_chan_def def; 765 766 lockdep_assert_held(&ar->data_lock); 767 768 list_for_each_entry(arvif, &ar->arvifs, list) { 769 if (arvif->vdev_id == vdev_id && 770 ath10k_mac_vif_chan(arvif->vif, &def) == 0) 771 return def.chan; 772 } 773 Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath10k/mac.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -4470,7 +4470,9 @@ static int ath10k_add_interface(struct i } ar->free_vdev_map &= ~(1LL << arvif->vdev_id); + spin_lock_bh(&ar->data_lock); list_add(&arvif->list, &ar->arvifs); + spin_unlock_bh(&ar->data_lock); /* It makes no sense to have firmware do keepalives. mac80211 already * takes care of this with idle connection polling. @@ -4603,7 +4605,9 @@ err_peer_delete: err_vdev_delete: ath10k_wmi_vdev_delete(ar, arvif->vdev_id); ar->free_vdev_map |= 1LL << arvif->vdev_id; + spin_lock_bh(&ar->data_lock); list_del(&arvif->list); + spin_unlock_bh(&ar->data_lock); err: if (arvif->beacon_buf) { @@ -4647,7 +4651,9 @@ static void ath10k_remove_interface(stru arvif->vdev_id, ret); ar->free_vdev_map |= 1LL << arvif->vdev_id; + spin_lock_bh(&ar->data_lock); list_del(&arvif->list); + spin_unlock_bh(&ar->data_lock); if (arvif->vdev_type == WMI_VDEV_TYPE_AP || arvif->vdev_type == WMI_VDEV_TYPE_IBSS) {