Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp415944rdb; Thu, 19 Oct 2023 08:05:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHO7hm5Z1b0IxSmBn+8iJtnQJMf/SAEsF+axvPgzaYyrAJwS6xNuQHr4w1Ck+mAvekpMXaq X-Received: by 2002:a17:903:26c1:b0:1ca:8e43:765a with SMTP id jg1-20020a17090326c100b001ca8e43765amr2291815plb.9.1697727918344; Thu, 19 Oct 2023 08:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697727918; cv=none; d=google.com; s=arc-20160816; b=R1yn3fuAH4Om+QnTprDDEPTb1gsbp4dsxa/sSg3T7CLejwL5KJBuLKTI35KsrFREH2 l+Dtm3FO3dpCXhWG1YHJQRmP2ELmfoybZ5cpqjFm0/Kx8FWghRfYojtf3eX3Pr7EJ6VQ Obh5oYJjSbYaW/WkZ4tvFwqMDWfxHZKjLooV4MB/3sjKtXMNWjgxneV09sGP6yrBGP+f BMYX/75XqFrdFgkS5X8FdV0PrvqK6skBw7SmZDBOr1mkpRdZ9B8nMFKVF+5FFlSKY8f3 jWdwu9sNuDqHL092xRJnPyHWYTrD+xMtru6d8a2NqP6PKOzwVGgIhk7T/uCQEhUujc34 qI2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qanLP9cmLj+5RCqf6a5RUipKVc/ue5qlpWjav39spJI=; fh=sCriQ7/2nt5D2vAB/Ra7jLtjWQdsqDRto1Qs6xfAg4c=; b=itv5LmNa/Z7zWmGWcV1t60WCVMW7SgWfFHgxlHpUZapIfJhufT+DefCVy7P5Oy1jq1 kiolM3cSZ29lWO3P7ciBQaB0e/hr9O4Y4haaO6yYdsdLg8WHTJOx/IraroPtD7Gs9SW7 KAZPYwg+yjKB/9mCqiZq1ytrwzfK3eDZh+8wV7MXJ+9N3qzr3oMxOxf+Eg+rClIDwXcK hbSdQ8gQPM5rS46AhzRh3HH3GYOjQXzWnZFnHoLYUAETxuPHTz9gWPvYBlPsjIDDeav/ D0/92ID3olpqdjlt1+yLEuL9u+/CIOW3tZKJG9Q52Zat2HKZNFR3QcV3OO0qx3yUPfw3 7HxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N55h2sDa; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ju21-20020a170903429500b001ca1bd194b4si2332750plb.416.2023.10.19.08.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 08:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N55h2sDa; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 75817823CE85; Thu, 19 Oct 2023 08:05:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346228AbjJSPFH (ORCPT + 52 others); Thu, 19 Oct 2023 11:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346174AbjJSPFG (ORCPT ); Thu, 19 Oct 2023 11:05:06 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D6B11D; Thu, 19 Oct 2023 08:05:04 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39JBTTpm015458; Thu, 19 Oct 2023 15:04:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=qanLP9cmLj+5RCqf6a5RUipKVc/ue5qlpWjav39spJI=; b=N55h2sDaxlOTr5cqyrZiCojGMyOT9NR8bSHs2F/gOzJ89WNMIKTr60vipNiPCo/+3Sns s9GKmNGFGb/DYAaUt51KrBwTsRDOmqq9aI588puJePZ50WEq/k/OSQRhtSUQvdaVLgbU gKP4qqzDrkaKFm7yAimUjb6A24J3vn3W3VAd/2CV+0vahAV8+ThzHw2QjQos7XCyFtHe WoQsyi+0ix57YBvgsGD7uVVlOsc0OPZuI5GcFh50kThYUBmFCxPzQ4az5BbvH8dFKzTJ a6se8ExXuw+V/Rqktd42HFEhGYI7WQgpkaL078xfrcxGyPb+KWMq8Vp/rR2lRG2yGep0 qg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tu14crsrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 15:04:57 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39JF4ujJ005265 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 15:04:56 GMT Received: from [10.48.241.70] (10.49.16.6) 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.1118.39; Thu, 19 Oct 2023 08:04:56 -0700 Message-ID: <4233c8af-5911-40bf-b5ba-dd0a63863a45@quicinc.com> Date: Thu, 19 Oct 2023 08:04:55 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] wifi: ath11k: fix temperature event locking Content-Language: en-US To: Johan Hovold , Kalle Valo CC: Pradeep Kumar Chitrapu , , , , References: <20231019104211.13769-1-johan+linaro@kernel.org> <20231019104211.13769-2-johan+linaro@kernel.org> From: Jeff Johnson In-Reply-To: <20231019104211.13769-2-johan+linaro@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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: LLFEGCv0SJ0xik2fPzfmGJ9UzfpCfQCs X-Proofpoint-ORIG-GUID: LLFEGCv0SJ0xik2fPzfmGJ9UzfpCfQCs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-19_14,2023-10-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=703 clxscore=1011 suspectscore=0 impostorscore=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310190127 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 08:05:10 -0700 (PDT) On 10/19/2023 3:42 AM, Johan Hovold wrote: > The ath11k active pdevs are protected by RCU but the temperature event > handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a > read-side critical section as reported by RCU lockdep: How do I enable this? Just enable CONFIG_PROVE_RCU? Of course I'd also need to exercise the code path... > > ============================= > WARNING: suspicious RCU usage > 6.6.0-rc6 #7 Not tainted > ----------------------------- > drivers/net/wireless/ath/ath11k/mac.c:638 suspicious rcu_dereference_check() usage! > > other info that might help us debug this: > > rcu_scheduler_active = 2, debug_locks = 1 > no locks held by swapper/0/0. > ... > Call trace: > ... > lockdep_rcu_suspicious+0x16c/0x22c > ath11k_mac_get_ar_by_pdev_id+0x194/0x1b0 [ath11k] > ath11k_wmi_tlv_op_rx+0xa84/0x2c1c [ath11k] > ath11k_htc_rx_completion_handler+0x388/0x510 [ath11k] > > Mark the code in question as an RCU read-side critical section to avoid > any potential use-after-free issues. > > Fixes: a41d10348b01 ("ath11k: add thermal sensor device support") > Cc: stable@vger.kernel.org # 5.7 > Signed-off-by: Johan Hovold > --- > drivers/net/wireless/ath/ath11k/wmi.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c > index 23ad6825e5be..980ff588325d 100644 > --- a/drivers/net/wireless/ath/ath11k/wmi.c > +++ b/drivers/net/wireless/ath/ath11k/wmi.c > @@ -8383,6 +8383,8 @@ ath11k_wmi_pdev_temperature_event(struct ath11k_base *ab, > ath11k_dbg(ab, ATH11K_DBG_WMI, "event pdev temperature ev temp %d pdev_id %d\n", > ev->temp, ev->pdev_id); > > + rcu_read_lock(); > + > ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id); > if (!ar) { > ath11k_warn(ab, "invalid pdev id in pdev temperature ev %d", ev->pdev_id); aren't you missing an unlock() in this error path? perhaps have a goto cleanup that does both the unlock() and the kfree()? > @@ -8392,6 +8394,8 @@ ath11k_wmi_pdev_temperature_event(struct ath11k_base *ab, > > ath11k_thermal_event_temperature(ar, ev->temp); > > + rcu_read_unlock(); > + > kfree(tb); > } >