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 ADA13429CD6; Thu, 16 Jul 2026 14:25:05 +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=1784211906; cv=none; b=Jpj4pVGDFZyEddAuev/8uCZhowaN2Z/s2E2Lg110fzqY2c4jlY6Uip9az2j2L9Zv15UoTORL+dxi+yuL+T/Aw/1oizn1WSYp05lJ2z+Dy/Nhw/3YS8JJOBtkt3BvWBx6IBJITVXFtBZhH0O0NDfqTq8CWjM0kr+nz6H4AHDuJA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784211906; c=relaxed/simple; bh=2h0iq/MPM6/4FsDVR6JA3t6Vt2BVWHHfDWffa/7Flns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qpQIC+N/tEp0I+HHfdukd8Hs8i79UP8Rb32qD4JjW/ZT7VpNT5brOsR8t+JL3H/MvxSYH7nVpOpLumfqqdijnFxSMo3Q31yoK/MY/k7cjd2uSvgJsuJxWJXybSiz32bFECBmRWCMCYZ1Oz/rmd2YHV0K50k2ERzbqFUaNKstqns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=psGQzVns; 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="psGQzVns" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 204351F00A3A; Thu, 16 Jul 2026 14:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784211905; bh=eFfhhlqintJJkKzCjJHmhD2DCURjXHbBo7KTx8Nk6ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=psGQzVnsChmv6rP1ZJ2yXD6JFHlOoMJ5+E0yf9nsldk1iIP76B+0s40h0+gZskEp/ WIIlDP2q7idcbg+fPJaCH8tnBHhOjk2cuJQsn3OPMJfClgvcH890mQXf//dFe9sBRM 9kBwon2ErXU0lmUI1Fgn+3XdPvtndavemaKyKtJc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Alexandru Hossu Subject: [PATCH 6.12 125/349] staging: rtl8723bs: fix OOB reads in is_ap_in_tkip() IE loop Date: Thu, 16 Jul 2026 15:30:59 +0200 Message-ID: <20260716133036.155250289@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133033.287196923@linuxfoundation.org> References: <20260716133033.287196923@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.12-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 @@ -1376,15 +1376,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; @@ -1392,7 +1400,7 @@ unsigned int is_ap_in_tkip(struct adapte break; } - i += (pIE->length + 2); + i += sizeof(*pIE) + pIE->length; } return false;