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 D90E7A59; Mon, 23 Mar 2026 14:22:03 +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=1774275723; cv=none; b=hR1jQevKDVjR8mt3mk6wFDuvAHO85LqUxQg5jG/GsrOmvqRtRI72U4I9ugHSU29Z9RKn52Y3Q2Vq4Xx5jcKDRCO88f7uXhLSieo8rnuSoZfFjIFDiE4V65nU9nAwIDdbnl0zg5hUFduqEfuvwyVisXcN7qAPcRNYDXTQeZz72hE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774275723; c=relaxed/simple; bh=PBQpOKme9glVFXX7GWWUT1GmGatcMoyek3/qeCPiHZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SRLmoXkHeAVcVuIMyq6WhdJk6/NuOkZeSa9pYqRZtN+SaNRlB4QE0kPnBnCufaBAS6Y14fbgHl11P2itigSOTku0E+Cn4TZJIsurgoIFLjrG7siRk9pHjx3MWn8Ym5TCdqP83Wz5mr0ZfRbYW+82pDvFRrNzVfgHgnTNZVsGYo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RdBFZAxh; 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="RdBFZAxh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CD66C4CEF7; Mon, 23 Mar 2026 14:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774275723; bh=PBQpOKme9glVFXX7GWWUT1GmGatcMoyek3/qeCPiHZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdBFZAxhj7FIVCyNE6tNP0o8W3gBJ7hmGifCPxuvHkr/reKj3441/YQYFZD3fccZx Z93+IM4Ql/TPNdUM2o3jm01JJ+Q8zvuLW1nykcncQLaFh5v88IKjTORToNue+yvlRd ZxKUSC+HL2onBwuxyhlnPkzveOGtFQ7TICEBWmi4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Luka Gejak , Dan Carpenter Subject: [PATCH 6.12 153/460] staging: rtl8723bs: fix potential out-of-bounds read in rtw_restruct_wmm_ie Date: Mon, 23 Mar 2026 14:42:29 +0100 Message-ID: <20260323134530.330035363@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134526.647552166@linuxfoundation.org> References: <20260323134526.647552166@linuxfoundation.org> User-Agent: quilt/0.69 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-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luka Gejak commit a75281626fc8fa6dc6c9cc314ee423e8bc45203b upstream. The current code checks 'i + 5 < in_len' at the end of the if statement. However, it accesses 'in_ie[i + 5]' before that check, which can lead to an out-of-bounds read. Move the length check to the beginning of the conditional to ensure the index is within bounds before accessing the array. Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable Signed-off-by: Luka Gejak Reviewed-by: Dan Carpenter Link: https://patch.msgid.link/20260224132647.11642-2-luka.gejak@linux.dev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1929,7 +1929,10 @@ int rtw_restruct_wmm_ie(struct adapter * while (i < in_len) { ielength = initial_out_len; - if (in_ie[i] == 0xDD && in_ie[i+2] == 0x00 && in_ie[i+3] == 0x50 && in_ie[i+4] == 0xF2 && in_ie[i+5] == 0x02 && i+5 < in_len) { /* WMM element ID and OUI */ + if (i + 5 < in_len && + in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 && + in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 && + in_ie[i + 5] == 0x02) { for (j = i; j < i + 9; j++) { out_ie[ielength] = in_ie[j]; ielength++;