From nobody Sun Feb 8 10:34:07 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 216292DB790 for ; Thu, 29 Jan 2026 18:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769710570; cv=none; b=qTb60AEmp3a91WjjlkpFYUt3fku3JjmIqKwYZUOOez8bOo5iHO91k1s4mKyD8NxPica/hVv/tkHCHXB7UvTRIejPKdE1zgonWnaIWRKnYKlYvAlTksfN2P0cP/DreJ7TvyhtJ3Gp8PwKptFOwf0sC0MqsOwW1odBi+EmBPe/n8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769710570; c=relaxed/simple; bh=anusSg+ei2G8pY99kSNGBiFGkxTuVaDv4F/ejqaSEKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UjCB4fbFtMdjuGywNrhGJ7aopt5fon+IGfm/dH6YJg8hxpVoGQTsmvSVL4kV+HzacpK1abuf8ywxLBZuDvhlwLTYNSv1KoMrES0g+0jDEVPZKwKfjRw7n+TYv7693vbz5aPyT+fFtBztKMDUVxzlw3NwzP7JSxTx78cfPuRezTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k0LGEX1n; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k0LGEX1n" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-47f5c2283b6so10364505e9.1 for ; Thu, 29 Jan 2026 10:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769710567; x=1770315367; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YkmQJfRqTQzrHHgjjnSwxvqZrCWnUDQPc30Wk1HVPk4=; b=k0LGEX1na3lo3P732hXVTAUHKW+aQG5Qc/hJZryrvCM87ON/dBBfi6cb2zh41ZYVqR ZpDMfom5nQzLIEFSe/YjjOdaabDSFuHCfYdwthStUicuG9hgjeh7IdVcRDIPb7V1zdlF spmXIMO8VY1RB39DnpVcdhJkJsT5+KFfDCoid85J+8w7SkRDz0QXR/Q/Ouu/WuUrP82c MgmUJycBHK0ZVOzjMv/66CnwoKAZhg3TMqQkdPnxEqaXPjssEnQPLrU5KAvi/uOh1L5y aD+qe82/1NdlhYefVsbfWnwT9pjduPpY4YIkuHYUvbxgEpt9YnJY1er/M2+V5DQMeJai BE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769710567; x=1770315367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YkmQJfRqTQzrHHgjjnSwxvqZrCWnUDQPc30Wk1HVPk4=; b=qyhLuYeHLc3n1P4mDMmko/CUvvActGRTznjt8LRYScMM7kFUcfBsQMQ6rmTY6+A6IV vGxyy0ltZn6kPpjEyJBmB77+jpnk4wjYfY/RXTkhz87d1xpvGyx1/yt7pBiUnNHLdjc2 nqGwhHLwlZkK2c5rVxTn/lqhOwpYuROkF7tlnyYQyTeiu00vOAeq4te4nYs5ibKOOSyu GQvvi0zIDEyonP0QTGmYuJiufFzVZhJl6m3r1dkCpi2GM627HO4V0JN66riY68qJ/o5D FPKf1DnUC0mWFeZrDAlYgbVc82msoH+ZDNbelLgGVTWsNSNHydFgFp/bWJ3FRVcXFczk jWIw== X-Forwarded-Encrypted: i=1; AJvYcCVQRGlk63uuHnP4IAzduftXQ2s4c0FVzJad7G1cWlM23qGYQyJkDkLK1UxNAleWOAyJjps2MaX78adf4as=@vger.kernel.org X-Gm-Message-State: AOJu0YwaZMkmfFQvLQTJSVr2EHw0oRueN/RIFVQ2SxoFbwqWc03rIX+J hCFBnti/TBYO61MpC229Yx4NtqMoTQj5paFy6BH8Sg+QDD/iTcWMwVbwo7qjxnU= X-Gm-Gg: AZuq6aK4vL/LYFQCqrJY1ZUJNcT66LNfbCzuScg/41kQWHoH6LEHvCxpCiVtCbO4qls sGj8SxrFQVpmCiwoUya1fLj5HP5DxTC7OoDEffrFQ8IR8tcaLObQiliBU631rW0g32Z/ZHOiwEl onUHoPl3LnMhC37aVY3zBvIgnUZoOqOIwcIQMK/rpCx7lMZ66mkuq++G9e7lhUar3O5VElUM1jE iq0J19Ncfg65pTOReOBzUbKXd2fxzi6DZ04ejvHFZxpMfxN6Wj61vUWlJFvL1LTEeHDG2ifacLR NoyJokKicPyl8kv0fM6YXwke60NssxY3EQYi6JexE8EDRdiev3THuXccsextNd2+YWdAEP3fqnm icZ8ESJncjQFb6h0zicvLsbej51lDifxWxOjzs4jpqPcEgApIfscByCkcv+ni01W0WU6dtwql7E nM X-Received: by 2002:a05:600c:4443:b0:477:7c7d:d9b2 with SMTP id 5b1f17b1804b1-482db4a1030mr491635e9.32.1769710567195; Thu, 29 Jan 2026 10:16:07 -0800 (PST) Received: from LGPC ([31.223.131.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4806cdebf86sm136578725e9.8.2026.01.29.10.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 10:16:06 -0800 (PST) From: Luka Gejak To: gregkh@linuxfoundation.org Cc: straube.linux@gmail.com, dan.carpenter@linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Luka Gejak , stable@vger.kernel.org Subject: [PATCH v4 1/5] staging: rtl8723bs: fix potential out-of-bounds read in rtw_restruct_wmm_ie Date: Thu, 29 Jan 2026 19:15:37 +0100 Message-ID: <20260129181541.72066-2-lukagejak5@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260129181541.72066-1-lukagejak5@gmail.com> References: <20260129181541.72066-1-lukagejak5@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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@vger.kernel.org Signed-off-by: Luka Gejak --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rt= l8723bs/core/rtw_mlme.c index 98704179ad35..7dfc2678924e 100644 --- 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 *adapter, u8 = *in_ie, u8 *out_ie, uint in_ while (i < in_len) { ielength =3D initial_out_len; =20 - if (in_ie[i] =3D=3D 0xDD && in_ie[i+2] =3D=3D 0x00 && in_ie[i+3] =3D=3D = 0x50 && in_ie[i+4] =3D=3D 0xF2 && in_ie[i+5] =3D=3D 0x02 && i+5 < in_len) = { /* WMM element ID and OUI */ + if (i + 5 < in_len && + in_ie[i] =3D=3D 0xDD && in_ie[i + 2] =3D=3D 0x00 && + in_ie[i + 3] =3D=3D 0x50 && in_ie[i + 4] =3D=3D 0xF2 && + in_ie[i + 5] =3D=3D 0x02) { for (j =3D i; j < i + 9; j++) { out_ie[ielength] =3D in_ie[j]; ielength++; --=20 2.52.0