Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2439646rwd; Wed, 14 Jun 2023 02:54:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ok3CvLFY8gNR1+2B6PV1Nfa8mccthfUON6ys55go/w2oIX1IYUeoH2Q/9oZUGkEBDzs0X X-Received: by 2002:a05:6359:2ea7:b0:125:4dd9:cf23 with SMTP id rp39-20020a0563592ea700b001254dd9cf23mr9996580rwb.12.1686736451914; Wed, 14 Jun 2023 02:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686736451; cv=none; d=google.com; s=arc-20160816; b=FinCpSoRjyR9XGvBDTRFfRPq/QzcwrFlo3N/CmKqlC7T8L+rQHTUnqvIGAvAYRdxYt BIa4+rzp7br+wTTQ6s8fPjn2o6NyTwdPXmz6VVkYAB4CLSRZr9vtl+Dx8O15dHt9R8La GFUSmL2E3TxOphZTJTJ3kj/0J3D2IgkqzhAzzlH6D+c5GbVSiDK2udYDheIHfqN3l1vP kzexvJp3j/ey8VeFvVxD485+2AhxBk+PozJRRyAr84tqicY2nC2fgq0HXD9SUaMWYJCf Ogc5t5DNzj0wJuxstnrTNfZ5STMQMdeLT5dLop5GM4FlkZgGtk38qMIDbzixCfNPqDuh zF5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UP6kApKOxzWhLJ1976GbmSl9v0nobu01En+sEelyYGs=; b=VL3jLVdOmwauK4KfwMj69HLwIE/oAW5HaaMOqeDSoXsgtAbEJKMQ2/Wl4u8VoLxSzo W+6wstx9JSzCVya4BEIzpgejlhvydfFS9ttL+TTxBMiyDfAW/73rT/U9x6E0CVsY7rRU INExZzQxS3mBAbv/OKAweE7XQU/SSM4GB52uolFB9gPFJKekJvs0pQVsyhH7wvmebbm4 tSKcnApn+voVVuWnsl6Z459QL8BcvVv3hvc6KySNSNuugBoAGyslFSMdqdiC4D8aOShc 58EPxArpXOvlcA7qIlkI1ZLCXre7V+BCnMDMKe4xMF7ovWcPDoNE2tbWGvx5hbuR/fT1 xY9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DAo91xqT; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a63754d000000b0051374678f95si10126437pgn.808.2023.06.14.02.54.04; Wed, 14 Jun 2023 02:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DAo91xqT; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235955AbjFNJpd (ORCPT + 62 others); Wed, 14 Jun 2023 05:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244332AbjFNJow (ORCPT ); Wed, 14 Jun 2023 05:44:52 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63322210A for ; Wed, 14 Jun 2023 02:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686735840; x=1718271840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8q9707cVDXua91kBBhuFJhXIcCmDI4MLuotMj/Gu2iw=; b=DAo91xqTtg0DCxp58xalSnbQCalsjdXfNo/kvRBcdVkwkC5w5tZJ3HhY M1ps90OSo8moEBzwcRvCItzrKgx9DE+82ZDayZGcfmzSsHI/ZddHTfC/m Aj5y1NLvro17TAB3A9N0c/wRrSQaAzWf3HAaChjd0Whg/UJN2tjwb+O/l zNJE+cCdgDwO4DKsOG1zVwDoXHpGbD6P+N+1fBKee5r8OsKSejv+/1Wi2 OyRToQI6RvJW7wRE7FzRndNQkGoG7xtdNSwPRIRVLpExZafxOd8BfHO0X Iyg5+vbdwAfqRMq4/DpmfCvA2D0YnuLoYWFtIBkL0q54NtUATWMr/2p0h Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="361049937" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="361049937" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 02:42:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="711989930" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="711989930" Received: from basharil-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.203.45]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 02:42:39 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Anjaneyulu , Gregory Greenman Subject: [PATCH 20/20] wifi: iwlwifi: add a few rate index validity checks Date: Wed, 14 Jun 2023 12:41:37 +0300 Message-Id: <20230614123447.79f16b3aef32.If1137f894775d6d07b78cbf3a6163ffce6399507@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230614094137.379897-1-gregory.greenman@intel.com> References: <20230614094137.379897-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Anjaneyulu Validate index before access iwl_rate_mcs to keep rate->index inside the valid boundaries. Use MCS_0_INDEX if index is less than MCS_0_INDEX and MCS_9_INDEX if index is greater then MCS_9_INDEX. Signed-off-by: Anjaneyulu Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 9 ++++++--- drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c index 687c906a9d72..4b1f006c105b 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. - * Copyright (C) 2019 - 2020, 2022 Intel Corporation + * Copyright (C) 2019 - 2020, 2022 - 2023 Intel Corporation *****************************************************************************/ #include #include @@ -125,7 +125,7 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) return idx; } - return -1; + return IWL_RATE_INVALID; } static void rs_rate_scale_perform(struct iwl_priv *priv, @@ -3146,7 +3146,10 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file, for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { index = iwl_hwrate_to_plcp_idx( le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); - if (is_legacy(tbl->lq_type)) { + if (index == IWL_RATE_INVALID) { + desc += sprintf(buff + desc, " rate[%d] 0x%X invalid rate\n", + i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); + } else if (is_legacy(tbl->lq_type)) { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), iwl_rate_mcs[index].mbps); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c index 23266d0c9ce4..74fbc4582453 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /****************************************************************************** * - * Copyright(c) 2005 - 2014, 2018 - 2022 Intel Corporation. All rights reserved. + * Copyright(c) 2005 - 2014, 2018 - 2023 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH *****************************************************************************/ @@ -1070,10 +1070,13 @@ static void rs_get_lower_rate_down_column(struct iwl_lq_sta *lq_sta, rate->bw = RATE_MCS_CHAN_WIDTH_20; - WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX || - rate->index > IWL_RATE_MCS_9_INDEX); + if (WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX)) + rate->index = rs_ht_to_legacy[IWL_RATE_MCS_0_INDEX]; + else if (WARN_ON_ONCE(rate->index > IWL_RATE_MCS_9_INDEX)) + rate->index = rs_ht_to_legacy[IWL_RATE_MCS_9_INDEX]; + else + rate->index = rs_ht_to_legacy[rate->index]; - rate->index = rs_ht_to_legacy[rate->index]; rate->ldpc = false; } else { /* Downgrade to SISO with same MCS if in MIMO */ -- 2.38.1