From nobody Fri Dec 19 17:17:57 2025 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.12]) (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 3897A17BB35 for ; Sat, 17 May 2025 07:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747468045; cv=none; b=m1KrxasuB31H6gTBf0DCrsdUKxpZzkd4745l56jAKOOWaaGz06dCId3LjSwJwzvIQ7ZT42oCQ0jPsPg/dkUVRAb3/3m5jO70IN7RG3l9UDLQltrzrwGfcUNZL+JhgQGbDcPZ7/qMFJS585D0jUeN76G0QiQnJdlKTFpxGDC0o6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747468045; c=relaxed/simple; bh=GzUx3qX8x8Ti/WYrmeDubgDgmu4jLi8bLsh1uhw67kY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UwXBgcxCWksloqoGJE4BPuZUSpxLSwGV78oam2mZkNIRuZoe1ETlE5j+1MfPfkpyt2iYzYW1EeAhl/Fo5eAqeqfcgC+nykGK2WU8JLRnYJsEWQYM526fvf0tK0RNJP3o3OZr7u9lklDYNd6VwCuUY/t+alICmlqUbuvH+EH4jJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b=BrNLLp+g; arc=none smtp.client-ip=212.77.101.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b="BrNLLp+g" Received: (wp-smtpd smtp.wp.pl 25770 invoked from network); 17 May 2025 09:40:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=20241105; t=1747467640; bh=vQzP50BnvI3iw2cFJFa5sluy2kEXYWbvimnAccLCu5M=; h=From:To:Cc:Subject; b=BrNLLp+garP4N8WaeTnMRagYwZpHQ7I6HOH5WNH4Or66u0Te/Ov1VGM9iPfCEzSjB XN9w+ZsSr4ZX61NM6YnIgi8YCUiRXXlKTDOIpT5E8fPJoiNjNOyVrmXIaeCUVe8Yv3 9TqZ3dvokEroZDA0fRAShrlSZV9OaqDjv2q3FXMoq6XLwPfUGz1v/16BYOcck0frCz ens3cmATBAZRVvwFAd31wHxaX3Mn0vbOJQ2SZ1cFH0Dk8KdqA9XplRMraKMwSGtS0b PV3b9Daw6C526l/CjINRvEefI90nYXK33NQ7zAx5Iaeaj/odicvm9bPkof/5jSEys/ lHLfHkeeJUgbQ== Received: from 89-64-9-114.dynamic.play.pl (HELO localhost) (stf_xl@wp.pl@[89.64.9.114]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 17 May 2025 09:40:40 +0200 Date: Sat, 17 May 2025 09:40:40 +0200 From: Stanislaw Gruszka To: Fedor Pchelkin , Johannes Berg Cc: Alexei Safin , lvc-project@linuxtesting.org, netdev@vger.kernel.org, Kalle Valo , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S . Miller" Subject: [PATCH] wifi: iwlegacy: Check rate_idx range after addition Message-ID: <20250517074040.GA96365@wp.pl> References: <20250424185244.3562-1-a.safin@rosa.ru> <20250427063900.GA48509@wp.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-WP-MailID: 779311392d6761ada01cae0109ceb9c8 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [sVOR] Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move rate_idx range check after we add IL_FIRST_OFDM_RATE for it for 5GHz band. Additionally use ">=3D RATE_COUNT" check instead of "> RATE_COUNT_LEGACY" to avoid possible reviewers and static code analyzers confusion about size of il_rate array. Reported-by: Fedor Pchelkin Reported-by: Alexei Safin Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c b/drivers/net/w= ireless/intel/iwlegacy/4965-mac.c index dc8c408902e6..2294ea43b4c7 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c @@ -1567,16 +1567,19 @@ il4965_tx_cmd_build_rate(struct il_priv *il, /** * If the current TX rate stored in mac80211 has the MCS bit set, it's * not really a TX rate. Thus, we use the lowest supported rate for - * this band. Also use the lowest supported rate if the stored rate - * idx is invalid. + * this band. */ rate_idx =3D info->control.rates[0].idx; - if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0 - || rate_idx > RATE_COUNT_LEGACY) + if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS) rate_idx =3D rate_lowest_index(&il->bands[info->band], sta); - /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ - if (info->band =3D=3D NL80211_BAND_5GHZ) + else if (info->band =3D=3D NL80211_BAND_5GHZ) + /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ rate_idx +=3D IL_FIRST_OFDM_RATE; + + /* Use the lowest supported rate if the stored rate idx is invalid. */ + if (rate_idx < 0 || rate_idx >=3D RATE_COUNT) + rate_idx =3D rate_lowest_index(&il->bands[info->band], sta); + /* Get PLCP rate for tx_cmd->rate_n_flags */ rate_plcp =3D il_rates[rate_idx].plcp; /* Zero out flags for this packet */ --=20 2.25.4