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 3B42743E07B; Tue, 21 Jul 2026 21:57:20 +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=1784671044; cv=none; b=kLa7JkR4RFrfqOuaM7uJJp7LpKTC7R/E1zFLY/OThj2KqPq90HKwZdWUdJhUZXI5WTrRpL9Hr60pxl9Cldw3AYEpN22XpA/SG8XFvR2GuD/po7pgvcPQO/A4FYuro9uqtthx/RKPkZtZ6TXLXBiYPh+MBQw3Gs/BPKf/wu3yQHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671044; c=relaxed/simple; bh=7tpY8fxKzpegWz8p2S8xNzZ42bUFF9cdJuD4SrQSp08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JNT9jI2BmvffnnQuDReXcwgmJ3msX9Nz50zZ+BD5WgmJsQHbHJyfsUktldJ3RAgEG18Chl+OHsQIzMoiHhm7BhO7GS3elbLC2d4H0yIx3Yeh4iFIdwvXJYqmJQIAUGOQ1YwH3pAj+GcNfwaKrEex2q17/JYB8dv/YoGRieKtUIw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=l4O5ukfV; 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="l4O5ukfV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ACEF1F000E9; Tue, 21 Jul 2026 21:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671040; bh=y4Ym/UWXj2MKHAGFtsdqdNg3AC6dnDW0fgH0heVIKQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l4O5ukfVoP/VLIY9rqwaXTiyli5LfsapjD0xk/+LCXUbaYLFnlLv9hAzLOUOKBeVX Ep57gC5L+plPQho8521IyRVHOdzGHPc45DjfUO4Pw8ScRJTtvevgLHndUIEyEutl01 vLJvNlEcSL6iWaM/AdYGsjWZndjImdCMp+mvqBJs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Alexandru Hossu Subject: [PATCH 5.15 097/843] staging: rtl8723bs: fix OOB reads in is_ap_in_tkip() IE loop Date: Tue, 21 Jul 2026 17:15:32 +0200 Message-ID: <20260721152408.182105160@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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 5.15-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 @@ -1381,15 +1381,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; @@ -1397,7 +1405,7 @@ unsigned int is_ap_in_tkip(struct adapte break; } - i += (pIE->length + 2); + i += sizeof(*pIE) + pIE->length; } return false;