From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7B511D2789; Wed, 2 Oct 2024 14:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727879349; cv=none; b=a93Eu4i733GbjMNzhr6fsPGkAsm35Ba7eflXAi0o1heC81+fki7qVsguz/8imoNpceMWJio5yzmefye7CNnw/JNNRpIi9h51ujTo90fm+lrQYlYSnqpGaBBauD8RhAfCor463oqfm9ebOO30Mo6BP3XmH7fIjlpu5Ftyfxy1MCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727879349; c=relaxed/simple; bh=/7KJkOMSnlsE9Ge/3tRbJpaZhDquOuPMC2xG5z0Qsxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rjc+KQhBRApkHc+D9l9bT8NUKdj5Nye18HlRSch5KwVbobgnBjnYRP+2pX/U6f+Tdeo5ZifIrTNStr/ZMgU0/uwLyj23O2dPs3GKX0KxDbbZEF2r37W52wNMlo20YdkalGyQxRfPdhG5TJQQjblvUlZdijPXjrWtZ9MbpmYvCWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C+nKoawl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C+nKoawl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64693C4CEC2; Wed, 2 Oct 2024 14:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727879349; bh=/7KJkOMSnlsE9Ge/3tRbJpaZhDquOuPMC2xG5z0Qsxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C+nKoawlJsch97qAutE4qMMqqfi9g4aHOEniscjLxd8cWEY5NEEd8bAlURCZ83kQ7 IQVP3YJKLikl3O167sAMTSRQFZOUE8ZbhU37v1f7RmDDj5opO6ILqHNFl3iVYjQxog 1RjOzGtEJN+vJC7UZRGI6g8aILQd49zLepuWwBm0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiawei Ye , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Kalle Valo , Sasha Levin Subject: [PATCH 6.6 061/538] wifi: wilc1000: fix potential RCU dereference issue in wilc_parse_join_bss_param Date: Wed, 2 Oct 2024 14:55:00 +0200 Message-ID: <20241002125754.616939342@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125751.964700919@linuxfoundation.org> References: <20241002125751.964700919@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiawei Ye [ Upstream commit 6d7c6ae1efb1ff68bc01d79d94fdf0388f86cdd8 ] In the `wilc_parse_join_bss_param` function, the TSF field of the `ies` structure is accessed after the RCU read-side critical section is unlocked. According to RCU usage rules, this is illegal. Reusing this pointer can lead to unpredictable behavior, including accessing memory that has been updated or causing use-after-free issues. This possible bug was identified using a static analysis tool developed by myself, specifically designed to detect RCU-related issues. To address this, the TSF value is now stored in a local variable `ies_tsf` before the RCU lock is released. The `param->tsf_lo` field is then assigned using this local variable, ensuring that the TSF value is safely accessed. Fixes: 205c50306acf ("wifi: wilc1000: fix RCU usage in connect path") Signed-off-by: Jiawei Ye Reviewed-by: Alexis Lothoré Signed-off-by: Kalle Valo Link: https://patch.msgid.link/tencent_466225AA599BA49627FB26F707EE17BC5407@qq.com Signed-off-by: Sasha Levin --- drivers/net/wireless/microchip/wilc1000/hif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c index e4bb3ea6e2267..25e881ee727cd 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.c +++ b/drivers/net/wireless/microchip/wilc1000/hif.c @@ -381,6 +381,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, struct wilc_join_bss_param *param; u8 rates_len = 0; int ies_len; + u64 ies_tsf; int ret; param = kzalloc(sizeof(*param), GFP_KERNEL); @@ -396,6 +397,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, return NULL; } ies_len = ies->len; + ies_tsf = ies->tsf; rcu_read_unlock(); param->beacon_period = cpu_to_le16(bss->beacon_interval); @@ -451,7 +453,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, IEEE80211_P2P_ATTR_ABSENCE_NOTICE, (u8 *)&noa_attr, sizeof(noa_attr)); if (ret > 0) { - param->tsf_lo = cpu_to_le32(ies->tsf); + param->tsf_lo = cpu_to_le32(ies_tsf); param->noa_enabled = 1; param->idx = noa_attr.index; if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) { -- 2.43.0