Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3029249rdg; Tue, 17 Oct 2023 02:17:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFED+58B698VdPTf8D3SdFzU9D+xh5sxiU7coN73isNBCFROYtGLXNhrepYfjegkyfNIRVf X-Received: by 2002:a05:6a21:1a5:b0:154:d3ac:2076 with SMTP id le37-20020a056a2101a500b00154d3ac2076mr1683479pzb.40.1697534253816; Tue, 17 Oct 2023 02:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697534253; cv=none; d=google.com; s=arc-20160816; b=ApKjwo1kQxjOwucEp4qicM0+RHUcOcYCjzPBS6GcXXoU8YWY6NiiYHQ9JBzH5m1cVB dcOeMrT+dGFtTTJPaMfF8H3Q385d17VFGCq0XDl/NRdKimaw3Gx6drFSI8P3l5QyOCw8 2bCuFIaG2ZRd7oEzTVCZdq6a/0mqWwVMOLt86obeBjxqLOXUZvLYFpqOhJAPGApwmZCg vYDTq3c1oUPgcSco6vwHfELxP0uF/+NqBwptya6LMXOCcUy3sbVuxSORMt2i+SvqkrYx aLwkb0qIFCasHLnmJYawiLEuwPEpS6kCVgqTonU2XGNcmOkwyBkfMUJLA6zNjw4vPWxj OKPw== 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=LuRbHy5zOajRnn0TNrfyn5mrH+MWB2gyIzb93yWDr3U=; fh=gZ7kD9qKtnlun0eYcs5tdznUCFo8Q3XgNORYUf7jH8g=; b=RaXPUaHapNntf/bNoTEVtZa8Hftjf14Rj2Ygi2fRBea5F7s/yX/N82OM8b0+17Sh84 zpC3bLIUsKemTT3KZ3rVw1COI2YexQTcBrV3T0fGjh1TEWn5m93C7rklBC+P3ur9BfBk LN1BSvHxCD9pv1gVxNXhHMns/OKWMmJDKo/bR6ijtvxUBGwliYbx3vmcDU+l75agru9A 9uH0t5F+Nfklkj+XTGw0dewahN03SACd2gRCwWbUuPkp+AjZiSreSMh7uoYGSncLLw3p bKL7eOUFXDnpljtOfOWa2u5zHWbYNTJYZZXB2S+hLqOTUjKxmTXQj90RmPwLKNcWxyYG zDFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e6tu8m0y; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l190-20020a6388c7000000b005775a0cd009si1321689pgd.331.2023.10.17.02.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:17:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e6tu8m0y; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1D152805DC68; Tue, 17 Oct 2023 02:17:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234842AbjJQJR3 (ORCPT + 52 others); Tue, 17 Oct 2023 05:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234838AbjJQJRZ (ORCPT ); Tue, 17 Oct 2023 05:17:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E166102 for ; Tue, 17 Oct 2023 02:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697534242; x=1729070242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qZ9JYoD7m1kKkUUuh7WagtJe5jacEAGtQMmsEQ+4IwE=; b=e6tu8m0yinznJgyf/xNQlCJ7a44k+GxbasJCTD5Jet+d8HWfaYS+FV+s 2dmMbB+5yWVG9UGJaud70CDygoKzhD6YhzUeP30kgo+U3ZODsXfUi0w0S k0/a2k70BImROdZy6vTL+PpxaXsHFnJYyrO9Qt++xbMh8fnUN4K67yW6t EO3Ue8Hr5VWb1UieHQMAK+6JNJAEzJBPUI0bZZItcKDW4m6Vpx4M3RL6e NvESLktxuxUHCiRxWrw0R19jukCtitURzXYsuQgOVVyDqbyeLmvb4e4ak oDRBeov5cABSfIbCHMZUhdXfkd68MSTqAZ9IQX/Qdf4UTuzKaJkKHgmhD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="370808554" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="370808554" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 02:17:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="759731934" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="759731934" Received: from obarinsh-mobl1.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.214.213.101]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 02:17:20 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Gregory Greenman Subject: [PATCH 09/14] wifi: iwlwifi: mvm: fix size check for fw_link_id Date: Tue, 17 Oct 2023 12:16:44 +0300 Message-Id: <20231017115047.3385bd11f423.I2d30fdb464f951c648217553c47901857a0046c7@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20231017091649.65090-1-gregory.greenman@intel.com> References: <20231017091649.65090-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 17 Oct 2023 02:17:30 -0700 (PDT) From: Gregory Greenman Check that fw_link_id does not exceed the size of link_id_to_link_conf array. There's no any codepath that can cause that, but it's still safer to verify in case fw_link_id gets corrupted. Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/mvm/link.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/link.c b/drivers/net/wireless/intel/iwlwifi/mvm/link.c index d0d5ebc03d53..c3831440a019 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/link.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/link.c @@ -60,7 +60,7 @@ int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, if (link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID) { link_info->fw_link_id = iwl_mvm_get_free_fw_link_id(mvm, mvmvif); - if (link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID) + if (link_info->fw_link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf)) return -EINVAL; rcu_assign_pointer(mvm->link_id_to_link_conf[link_info->fw_link_id], @@ -243,7 +243,7 @@ int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, int ret; if (WARN_ON(!link_info || - link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID)) + link_info->fw_link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf))) return -EINVAL; RCU_INIT_POINTER(mvm->link_id_to_link_conf[link_info->fw_link_id], -- 2.38.1