Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3564723pxf; Mon, 5 Apr 2021 15:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA90mgv8ZPgaKTWeh5FsIta+lIll/q2O/J/XFnzQvgt2hGqrPqG2LvbRrqlSiC42pQvLuP X-Received: by 2002:a92:cd88:: with SMTP id r8mr22096607ilb.152.1617663515148; Mon, 05 Apr 2021 15:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617663515; cv=none; d=google.com; s=arc-20160816; b=rNzdhTB8OVhudmPtr9C4LxyIE+n9CPVzLDjXBtHFl9QXn6+1/9Lr2vY8/4R1IpHoM0 hJ9EUebd+seS9rfxKP5WRMcUgc3gM5/i8nX8vBAV24T2osKBKOn7NJSgIE8cw5VQC4Pl V2fBEZrM8H7AD9Cay5tBag3O7XNHt6kgbKhnghZtXQkziApJB7s2dZ7If7I8MsOcUe85 dXD2K2EcF1QeZiC4MRg2bWaDA6qWW51dCcCg2oUN84vdl287BklYFtl96r6XKNVwrVDp zeXKH7vnx8cDEGy4mwYY9Wxn+SScbXbofgvFeKQKcLT8TT6BBpr74BBfXTYGhZ22CSWM BdhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YDE6v/9hmTbrCrWL6Qq2Y3FvXupzZkM0RVLUSTdPq7A=; b=Hp40BorFRHLRezv4TYdhb3FmmG8Qr6u10iFa+O3ydnOSEEaiJ00qRpymrKEs4P9eGH TrQtDDq7GZ7eaVnIMqBAMq7dg+ivF1hMVI2FCu0cOqYpGvivk+xHfTT25EhzowK/bMZS WvUHotre4mtgQ6Xykq2KGRQ5o4hd9SrJVutWyQumojYAG7v1cKKBZ9/o3NxJzljb7UWK 4TXURRZ1l8bL2E9FNVF6VISC0EExmH3vI9Y30fsY3CkIO1/c1kDuC9LKmDWLmA9glfiL OktyKMCvzxML1yNwP7bceN4EJrtlQsxaA6u/gzZegjzNr1Td2dKSEMikN62UWza4Raoo EY7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s21si15945897iov.70.2021.04.05.15.58.23; Mon, 05 Apr 2021 15:58:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238378AbhDEPfA (ORCPT + 99 others); Mon, 5 Apr 2021 11:35:00 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:47818 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238291AbhDEPfA (ORCPT ); Mon, 5 Apr 2021 11:35:00 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 2AFE51C0B7D; Mon, 5 Apr 2021 17:34:53 +0200 (CEST) Date: Mon, 5 Apr 2021 17:34:52 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Shuah Khan , Kalle Valo , Sasha Levin Subject: Re: [PATCH 5.10 047/126] ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr() Message-ID: <20210405153452.GC32232@amd> References: <20210405085031.040238881@linuxfoundation.org> <20210405085032.596054465@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9Ek0hoCL9XbhcSqy" Content-Disposition: inline In-Reply-To: <20210405085032.596054465@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9Ek0hoCL9XbhcSqy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > Fix ath10k_wmi_tlv_op_pull_peer_stats_info() to hold RCU lock before it > calls ieee80211_find_sta_by_ifaddr() and release it when the resulting > pointer is no longer needed. It does that. But is also does the unlock even if it did not take the lock: > +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c > @@ -576,13 +576,13 @@ static void ath10k_wmi_event_tdls_peer(struct ath10= k *ar, struct sk_buff *skb) > case WMI_TDLS_TEARDOWN_REASON_TX: > case WMI_TDLS_TEARDOWN_REASON_RSSI: > case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT: > + rcu_read_lock(); > station =3D ieee80211_find_sta_by_ifaddr(ar->hw, > ev->peer_macaddr.addr, > NULL); > if (!station) { > ath10k_warn(ar, "did not find station from tdls peer event"); > - kfree(tb); > - return; > + goto exit; > } > arvif =3D ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id)); > ieee80211_tdls_oper_request( > @@ -593,6 +593,9 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k = *ar, struct sk_buff *skb) > ); > break; > } > + > +exit: > + rcu_read_unlock(); > kfree(tb); > } The switch only takes the lock in 3 branches, but it is released unconditionally at the end. Something like this? Best regards, Pavel Signed-off-by: Pavel Machek (CIP) diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wirele= ss/ath/ath10k/wmi-tlv.c index e7072fc4f487..e03ff56d938b 100644 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c @@ -582,20 +582,19 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k = *ar, struct sk_buff *skb) NULL); if (!station) { ath10k_warn(ar, "did not find station from tdls peer event"); - goto exit; - } - arvif =3D ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id)); - ieee80211_tdls_oper_request( + } else { + arvif =3D ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id)); + ieee80211_tdls_oper_request( arvif->vif, station->addr, NL80211_TDLS_TEARDOWN, WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE, GFP_ATOMIC ); + } + rcu_read_unlock(); break; } =20 -exit: - rcu_read_unlock(); kfree(tb); } =20 --=20 http://www.livejournal.com/~pavelmachek --9Ek0hoCL9XbhcSqy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmBrLhwACgkQMOfwapXb+vKkJACfX2IZWhZgB25cUE0Z9ij0EH75 eOAAnAnqYgGWEgn9M4c0O1zko9JRR4DE =QVpV -----END PGP SIGNATURE----- --9Ek0hoCL9XbhcSqy--