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 ECF7F2FFFA4; Mon, 13 Apr 2026 16:26:26 +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=1776097587; cv=none; b=cJ10bJ5fS4tXDrxqIkdEasf9BZCqiC7z9TNSXDoun6LLEroD4YYmdBwEGHTMtoONTUmhIFSQ3tx41v1DBao1UW2xmGvc1htMtFzo72wdaK6tGRGHFJefuFkKZmS7p5MIAeM6VY6/9WdvR0qmcRF/mkduumbySVLegnKxOLmOKcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097587; c=relaxed/simple; bh=t81HDDCeR6iTZO3dVDFW8gcT89TLZewVlZdIfGC+HP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCBazp8PkV9s3zTuVdEf7DpTfASjgpu8slUfDU1x2ot/LfCR+VIh2CaGlXyzc7nmZanDVoGR+DuJ/V89hsNA+grX4y5GT0qx5OQ4ri8w2nRPI/99dk5hvRtqWRZAm57vKIJ14UuSgm/ny6bqPL89XaIHwaCip5v2vwjZ4CCAsLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sGApuekX; 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="sGApuekX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83F23C2BCAF; Mon, 13 Apr 2026 16:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776097586; bh=t81HDDCeR6iTZO3dVDFW8gcT89TLZewVlZdIfGC+HP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sGApuekXnJSmEmqJR9sxJ7xnFJA9WUVYGsCviNbw6iblX+AZSIMhNS1eZG/kZRVux EemsVdrsh4gjdnJgERjYr3mTM1eP29A9kGwRLhH8qEDM3SJvZzvAbm+jokO/Q4rL0/ 5yUoC1RtNDYNS3xobjvSZeEghnCYnaXuoIf3BBDM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Navaneeth K Subject: [PATCH 5.15 162/570] staging: rtl8723bs: properly validate the data in rtw_get_ie_ex() Date: Mon, 13 Apr 2026 17:54:53 +0200 Message-ID: <20260413155836.519917723@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@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: Greg Kroah-Hartman commit f0109b9d3e1e455429279d602f6276e34689750a upstream. Just like in commit 154828bf9559 ("staging: rtl8723bs: fix out-of-bounds read in rtw_get_ie() parser"), we don't trust the data in the frame so we should check the length better before acting on it Cc: stable Assisted-by: gkh_clanker_2000 Tested-by: Navaneeth K Reviewed-by: Navaneeth K Link: https://patch.msgid.link/2026022336-arrange-footwork-6e54@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -187,21 +187,25 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len cnt = 0; - while (cnt < in_len) { + while (cnt + 2 <= in_len) { + u8 ie_len = in_ie[cnt + 1]; + + if (cnt + 2 + ie_len > in_len) + break; + if (eid == in_ie[cnt] - && (!oui || !memcmp(&in_ie[cnt+2], oui, oui_len))) { + && (!oui || (ie_len >= oui_len && !memcmp(&in_ie[cnt + 2], oui, oui_len)))) { target_ie = &in_ie[cnt]; if (ie) - memcpy(ie, &in_ie[cnt], in_ie[cnt+1]+2); + memcpy(ie, &in_ie[cnt], ie_len + 2); if (ielen) - *ielen = in_ie[cnt+1]+2; + *ielen = ie_len + 2; break; - } else { - cnt += in_ie[cnt+1]+2; /* goto next */ } + cnt += ie_len + 2; /* goto next */ } return target_ie;