From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 67BBA400981; Thu, 16 Jul 2026 14:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210756; cv=none; b=E3SnMpjXqSHjmvS6Heb6Jx/hu380EqmDTpeaqm8v3IoAjqDSBdd4QUS2t7C2f7tjq+JRETdTTWZK+T2lf6M9RKu3nP2+K7OVO8bxOaW3ZNuCfTymRUlmKMGEBF+cKJqHHEbLLwyD0xFyQJKcLeWSgpXALsQBLsbiP7THkehJuTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210756; c=relaxed/simple; bh=aN/3YVUSNj5wQSrPFSRzjfYdzVq5sOzrQ+CFVK4gJaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D8JKBWcHPzSEIZ/KEtgco8FCyvQyAB4W6fX6GQPjkR6jLgvYxVETy2AiQ4OGRN0VA/zBfbU/TEWb0Tt2JVAUpA+2eRMWhB1OX/HgSc6ok3FN93qYtuZopnqsghm7swZKRXLgcGdp7vlBkLe6Is6CCx0gAXKjYejlr8UKe5LYkcs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eO/X6z2y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eO/X6z2y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC3EF1F000E9; Thu, 16 Jul 2026 14:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784210755; bh=I/MWnWJI/sahJozrRR4nlM+6xEcfnifXVCMiGwmD2+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eO/X6z2yhSBIy9GgvKskvnFVHZmY+KjVANZMTUPmaipds/2j3GyR8bYPYXmmt80la Q7lA2YsoO4foBNKc6C77Ko0dH2yy10lQFS7oDPuE9wGhVjA4M18LE48EQm0k7eHU8Z z1bwsGzg78v0AGlctOS7ZMQRUZsvS6KiCLRm2eRY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Alexandru Hossu Subject: [PATCH 6.18 167/480] staging: rtl8723bs: fix OOB reads in is_ap_in_tkip() IE loop Date: Thu, 16 Jul 2026 15:28:34 +0200 Message-ID: <20260716133048.320059002@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133044.672218725@linuxfoundation.org> References: <20260716133044.672218725@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexandru Hossu commit 3bf39f711ff27c64be8680a8938bcc5001982e81 upstream. The loop in is_ap_in_tkip() iterates over IEs without verifying that enough bytes remain before dereferencing the IE header or its payload: - pIE->element_id and pIE->length are read without checking that i + sizeof(*pIE) <= ie_length, so a truncated IE at the end of the buffer causes an OOB read. - For WLAN_EID_VENDOR_SPECIFIC the code compares pIE->data + 12, which requires pIE->length >= 16. For WLAN_EID_RSN it compares pIE->data + 8, requiring pIE->length >= 12. Neither requirement is checked. Add the missing IE header and payload bounds checks and guard each data access with an explicit pIE->length minimum, matching the pattern established in update_beacon_info(). Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable Signed-off-by: Alexandru Hossu Link: https://patch.msgid.link/20260522004531.1038924-7-hossu.alexandru@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1333,15 +1333,23 @@ unsigned int is_ap_in_tkip(struct adapte for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) { pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i); + if (i + sizeof(*pIE) > pmlmeinfo->network.ie_length) + break; + if (i + sizeof(*pIE) + pIE->length > pmlmeinfo->network.ie_length) + break; + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) + if (pIE->length >= 16 && + !memcmp(pIE->data, RTW_WPA_OUI, 4) && + !memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4)) return true; break; case WLAN_EID_RSN: - if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) + if (pIE->length >= 12 && + !memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; break; @@ -1349,7 +1357,7 @@ unsigned int is_ap_in_tkip(struct adapte break; } - i += (pIE->length + 2); + i += sizeof(*pIE) + pIE->length; } return false;