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 90A9C2517AF; Mon, 23 Mar 2026 15:07:45 +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=1774278465; cv=none; b=Z87jcAlgzv0nJTuQ1r/M+M8q+of1+pymIOtC0HjIpl5LLKpAIhRu+LJn0BU3NseQw55guxrRX5wWoI8nbDuuu+TFg1rp8JlcUfczaw1uRCrbCKAqMe2n/WChNp5yNry+VNT/LxF07mq/fGzDxoTNmey1f7knt9+WJ5kDZ9lyhKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774278465; c=relaxed/simple; bh=nkm2w9LVeM+tTQOVFpsWPtNwhrnW1Bjt9ocW/WcVOxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DPyeAk4e4PfbBm/cGHrb859mMTc0522Lf63yQs1vZpli6ZwAWrmWI7PprpgdrwArgvkuovfAKwEtWjr6e89q8NQN/2i+wXs2aW/o5TmHqwq+hlWzEy4GcPOIV9DIYKsWFDNLIu4JL/M6N6GHwaZtNNwn5dhcENxPiGdMgxhxhJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p4tzN4xB; 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="p4tzN4xB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FB3FC4CEF7; Mon, 23 Mar 2026 15:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774278465; bh=nkm2w9LVeM+tTQOVFpsWPtNwhrnW1Bjt9ocW/WcVOxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p4tzN4xBY8ExQdyrJeGhlEgtPBUAflSzcR0Ze2aXxP9DZTmNktx+PPgM0dFoV7mpo oVGfYW67qTfCztVQJtvMTTsuUaEZJ6C+/myki/mK4AIZLDP7dhaUmTIXnooggDPGqp TSBKPJjyAazZo9xkjBoLqMC20Je99ZT4z9enBpto= 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.6 315/567] staging: rtl8723bs: fix potential out-of-bounds read in rtw_restruct_wmm_ie Date: Mon, 23 Mar 2026 14:43:55 +0100 Message-ID: <20260323134541.621160852@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134533.749096647@linuxfoundation.org> References: <20260323134533.749096647@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.6-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 @@ -2000,7 +2000,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++;