Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp436568rdb; Thu, 19 Oct 2023 08:33:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHa57R1jX6dQJIEXcTlCadUD6KNf3/8mj8AmeeVC0qDqTmdqKe0XSjG8QpBsgSyXcHTUF// X-Received: by 2002:a17:902:fa83:b0:1c6:1d3d:b412 with SMTP id lc3-20020a170902fa8300b001c61d3db412mr2482454plb.30.1697729588182; Thu, 19 Oct 2023 08:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697729588; cv=none; d=google.com; s=arc-20160816; b=f1rvh7Baq7KN3tNpeJdskGkCpTy0++OQgse2/cZD3wsrlzO/gZoY7LycdfAWlBZXYm z9YSSjy0OTSU7cRBm78MDyU7u3BdVsc4a3zNGKvqa24OoV+k/THqejkox0Z7JzqUphgW azFybCXYgfSsZQdwDb09BEnkenx81rOaL3D1qo2Vcn7eBtlsDrlQO1rkRtoXgfJZfkLg B1mRS9uS1VEFdlAA6ZXK+ka+0M4tE4ZOoSbHm8QMTpXXsIP9qPruYGmIvX28YCjiWNKn yjdcKGXJgk/9c9gC0PZMQTylOblEDlnx3Lpbvt6mlvo/eH9QUQKPFXuSxlePu6XeVSK2 Spdw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LoGQRqJtynk6BmA2y7HxZj45goR1gDAV0mk2dlVp8Jk=; fh=wVjIh4Ry7X7gqxD7x4+f60lKPnJwP7xEuzok5FQ1a8Q=; b=cy/DTgvOkaWSnw1hNXPn4daVTkyYhIHWHDwWx8+TUrcrmwo7SpyoFsouRgtjkm8vWV aeRFiH/VDub9coSfV2koQ0xbAS/mhp2OkWylZI/te4InHw5ezCM9eMYOV1LFZRPZalPy WfAVbzbKiqqUtd4t+s0nuy2GTthYngGRDThTXlENs1do6g1WFe1NOr+y0PfMndzAvVyK LVWw17oeHvf6HUTG7Hfnosda1jasQXUYzbaZAR32rjIMucmlYYe3n2Skk++KSdP/DvGy n67IkTBQrLpnz5iBIlfNaqXpP7Dyr3QLEXqlIFeIzMR5BxwgODCv6Q36XO7iN2OUuv8I u95g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WPXJJ494; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id i19-20020a170902eb5300b001c60de17b5esi2367202pli.118.2023.10.19.08.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 08:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WPXJJ494; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4681982516D5; Thu, 19 Oct 2023 08:33:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346294AbjJSPdA (ORCPT + 52 others); Thu, 19 Oct 2023 11:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345965AbjJSPc6 (ORCPT ); Thu, 19 Oct 2023 11:32:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9465132; Thu, 19 Oct 2023 08:32:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F38EC433C7; Thu, 19 Oct 2023 15:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697729576; bh=ybnrjlLviCjSD8GSKMljRyMDeDtfP4Uw7YCw85cfwvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPXJJ494N+eQZDwnrF5/v4p3ljxHkhrb79+NS63aMaP8W7GUKRqOqEEWUV/LreBag HTxotFRSHtLz/rFWarbLOJNw1T2cWLMnZdVQ335Hp2fEyrar9dvQO05e82mbwu5yKq DTjzRvqhCmIJWpe1BO4BmxWi5s8ogvv3+H5rjW/jO53qoFb6ZaVbwdMcZz7Z/p8Rws UQzf2yGkDD8Me+A2p5mgUwCArQEExqPnb85OvdAndNgu2aZjBRI1AvVW4JCOqHNYFq iUOofKwV48HRgk75KinzjO9cPqCR5y7YtmJ3e191nYLXKnfqUq/IwCffYcSxO7pzTy brbnGVQpzxGug== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qtV1A-0006tA-0W; Thu, 19 Oct 2023 17:33:00 +0200 From: Johan Hovold To: Kalle Valo Cc: Jeff Johnson , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 1/2] wifi: ath11k: fix temperature event locking Date: Thu, 19 Oct 2023 17:31:14 +0200 Message-ID: <20231019153115.26401-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019153115.26401-1-johan+linaro@kernel.org> References: <20231019153115.26401-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 groat.vger.email 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 (groat.vger.email [0.0.0.0]); Thu, 19 Oct 2023 08:33:01 -0700 (PDT) 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: ============================= 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 23ad6825e5be..da1582b8dc30 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -8383,14 +8383,17 @@ 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); - kfree(tb); - return; + goto exit; } ath11k_thermal_event_temperature(ar, ev->temp); +exit: + rcu_read_unlock(); kfree(tb); } -- 2.41.0