Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8445597rwb; Wed, 23 Nov 2022 22:41:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cK96Zo+x6kETCHsRFpTNyTb+zU0oiSBL2coR95lNFL2hNMwWgrJprIpxPCDRVzPfk4iK1 X-Received: by 2002:a17:902:6b8b:b0:188:a40b:47c9 with SMTP id p11-20020a1709026b8b00b00188a40b47c9mr12337719plk.75.1669272109458; Wed, 23 Nov 2022 22:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669272109; cv=none; d=google.com; s=arc-20160816; b=XVTGutbeExO14dQ0uq0X1VbXFsMebeWexeGZvLQlZqqQgT1CV0Iuk0KCumlyc21mzj PXSOzXAZdS8t5J0DzAkCca5v8RR6cz9II7qGLmePoKy3B63e9OpyO+D3LL1LFtmX7jB9 1UW/Uzmfl9Bf/flDcE7tyu0mNYClyGW/HfKUekOmj3pzGKmghvwS3xEurxmMdo4pKU3f epQKVBLgX8CytMmqCAXL3OZah9cAEaicG+MtUGDS2JLJN5JcFx2be9J/xyXhcmOiGgB+ IUUBU+twx8LskzGk86cPgHR5wQSArdcrttFdAfMd1TN7HHW5u6goGVCIAxj7u/oliH4o 9SOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mXexrJEw2bptGf83p7kX6EVbTxiuwKnQaYQNpat7EOg=; b=jXotdG50NfBPkt797ZQaftmECnSJmhJ0v24QUAA7IhsZKWHu5Xgc88/MHQtGL68qGz IvjlzjSealXp0E4eAMww+OdbmCJMuHTzTDiUD1cmo5T/G/RGZnj/ooR+HDgJijRL+DiG nmxYI5N9UAv3I0cn+LMMLczm+4RxdAaPZQjyKpgFF6Wi/QlbFb+MF20ieZ5ENap3lClY ak2hE4ojk3qBbL21i/1C5SBkD5tZwFp62auBBe6SVdCKESfU4fyedneRvZqJNruuyfeL o9Zrw7gkVpBXA0rj/CU0msCmPiXw/2jFqfrMZjBl37pZcwz8HeR1zQEjTBhKzvHwAPL2 RBQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JXNWYMCW; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a63520a000000b004779a46866csi276726pgb.563.2022.11.23.22.41.39; Wed, 23 Nov 2022 22:41:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JXNWYMCW; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbiKXGhd (ORCPT + 68 others); Thu, 24 Nov 2022 01:37:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiKXGhb (ORCPT ); Thu, 24 Nov 2022 01:37:31 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B097DEAD6 for ; Wed, 23 Nov 2022 22:37:22 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AO4n8XA032604; Thu, 24 Nov 2022 06:37:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=mXexrJEw2bptGf83p7kX6EVbTxiuwKnQaYQNpat7EOg=; b=JXNWYMCWsbDLd3lc0+isL7qQbys3UVCpLe+QmqIL4ymV67V5oscltTRg3EkohSbPkRgL ZZ/UJ9HJlGSMGgL4M46eJ3YaEce2ilSuBcZlflCV4wGKoynaTvox5hnpaj/HyKmwnPJS IqSk4adksZAAnGIgGd6LtyvNV7qCv9+4DzU6CQns6JXNS9gyl/2PZRj32mWZrMSxphmh 31UEY5Q/k3orMD3iV63uk4qANH/3X8wKi+1I5nBad8bNCRxhodMRARJfNkDhdbmGWwVf EQiPc2vrL+QOiO6CAat4WQ97NyyXLWLn4/LMFIxYqjV0nl4AkoSm3yTcdoysQIJ2F+je 0w== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m0nsjem79-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 06:37:17 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2AO6bGPl010232 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 06:37:16 GMT Received: from kathirve-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 23 Nov 2022 22:37:14 -0800 From: Karthikeyan Kathirvel To: CC: , Karthikeyan Kathirvel , Govindaraj Saminathan Subject: [PATCH] wifi: ath11k: Fix race condition with htt_ppdu_stats_info Date: Thu, 24 Nov 2022 12:06:57 +0530 Message-ID: <20221124063657.2841-1-quic_kathirve@quicinc.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: -1xiDxMMPpACTjF6WbqUc_XvpCwTGZLg X-Proofpoint-ORIG-GUID: -1xiDxMMPpACTjF6WbqUc_XvpCwTGZLg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-24_04,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 spamscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211240050 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The below crash happens when running the traffic with multiple clients Crash Signature : Unable to handle kernel paging request at virtual address ffffffd700970918 During the crash, PC points to "ieee80211_tx_rate_update+0x30/0x68 [mac80211]" LR points to "ath11k_dp_htt_htc_t2h_msg_handler+0x5a8/0x8a0 [ath11k]". ppdu_stats_info is allocated and accessed from event callback via copy engine tasklet, this has a problem when freeing it from ath11k_mac_op_stop. Add spin lock to protect htt_ppdu_stats_info and to avoid race condition when accessing it from ath11k_mac_op_stop. Tested-on : IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 Signed-off-by: Govindaraj Saminathan Co-developed-by: Karthikeyan Kathirvel Signed-off-by: Karthikeyan Kathirvel --- drivers/net/wireless/ath/ath11k/dp_rx.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index c5a4c34d7749..2384c8c3c55c 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -1535,11 +1535,11 @@ struct htt_ppdu_stats_info *ath11k_dp_htt_get_ppdu_desc(struct ath11k *ar, { struct htt_ppdu_stats_info *ppdu_info; - spin_lock_bh(&ar->data_lock); + lockdep_assert_held(&ar->data_lock); + if (!list_empty(&ar->ppdu_stats_info)) { list_for_each_entry(ppdu_info, &ar->ppdu_stats_info, list) { if (ppdu_info->ppdu_id == ppdu_id) { - spin_unlock_bh(&ar->data_lock); return ppdu_info; } } @@ -1553,16 +1553,13 @@ struct htt_ppdu_stats_info *ath11k_dp_htt_get_ppdu_desc(struct ath11k *ar, kfree(ppdu_info); } } - spin_unlock_bh(&ar->data_lock); ppdu_info = kzalloc(sizeof(*ppdu_info), GFP_ATOMIC); if (!ppdu_info) return NULL; - spin_lock_bh(&ar->data_lock); list_add_tail(&ppdu_info->list, &ar->ppdu_stats_info); ar->ppdu_stat_list_depth++; - spin_unlock_bh(&ar->data_lock); return ppdu_info; } @@ -1586,16 +1583,17 @@ static int ath11k_htt_pull_ppdu_stats(struct ath11k_base *ab, ar = ath11k_mac_get_ar_by_pdev_id(ab, pdev_id); if (!ar) { ret = -EINVAL; - goto exit; + goto out; } if (ath11k_debugfs_is_pktlog_lite_mode_enabled(ar)) trace_ath11k_htt_ppdu_stats(ar, skb->data, len); + spin_lock_bh(&ar->data_lock); ppdu_info = ath11k_dp_htt_get_ppdu_desc(ar, ppdu_id); if (!ppdu_info) { ret = -EINVAL; - goto exit; + goto out_unlock_data; } ppdu_info->ppdu_id = ppdu_id; @@ -1604,10 +1602,13 @@ static int ath11k_htt_pull_ppdu_stats(struct ath11k_base *ab, (void *)ppdu_info); if (ret) { ath11k_warn(ab, "Failed to parse tlv %d\n", ret); - goto exit; + goto out_unlock_data; } -exit: +out_unlock_data: + spin_unlock_bh(&ar->data_lock); + +out: rcu_read_unlock(); return ret; base-commit: 007979876af42db35d793765c72d665bd812d919 -- 2.38.0