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 728851AED3B; Wed, 25 Sep 2024 12:00:26 +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=1727265627; cv=none; b=AmmAzTpXaHtTf5pJXEz11h5/7KQwJ5FJs50WkZsz39qyTIXXHP2wvWAbaS4cdmtm8Mlhw0IGNb9FReBpxbTL4xfWSNc12d0nBImGUoXook6i58jcAeIpI8Moyhhkhndr5qVRZM+nHSwFQxgMYF50789FDXTa6aZMxjw3HR/FEW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727265627; c=relaxed/simple; bh=f6KX9I8pgWXSxgX/4d9LiWvzGjiAh3upeSopzPw3ZbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e4sgF1mSmKDOnpYn0+aPDkcpI8K51b/VjsS65IiRgScvOLO80KLt8Fp6rnhjS9YeiADTTq2nmTf1iMRSPkmolgxD6WLL7F4Ot10oqd5Tb5Jv3ftA57q1+CuPZRbfHZrtHJzlsceSQiIEq2r5QistsouzzOAreJ/v2uAEYL5v+XQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IcGzJnUZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IcGzJnUZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86FACC4CEC3; Wed, 25 Sep 2024 12:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727265626; bh=f6KX9I8pgWXSxgX/4d9LiWvzGjiAh3upeSopzPw3ZbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcGzJnUZfOQRhbxVVqwx4dcyqZPibKmMv8W0eJFocMl09HrERQy99B0zQb8ZpwZV2 UnfgjsXOGmyfoaRwtMjiRwiMyqjvGkWBcRQdX9VKs5dVWyl3VC19eWG5yqURDeVcWF +4oVqYjlBdlfSc2QwDuNPmDQGeQAm7mOf8wXVkRICk/odD66njoR/4MyNGfdNIzdX/ yohQhKzDxNkwuWMzX1rX+f7guqkaqwaMrX15v3DKCgpHwbKwtJOGMumzTFVMsAX/pI xrfe2JN5fkxtHRnjp1ddH1zpI5iVPrcGgJvGpVYYg/rNQOV+fRvsnx8NDBy2t7lBHj uRTOvgnThev4Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Miri Korenblit , Johannes Berg , Sasha Levin , kvalo@kernel.org, gregory.greenman@intel.com, davem@davemloft.net, shaul.triebitz@intel.com, emmanuel.grumbach@intel.com, daniel.gabay@intel.com, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 6.10 051/197] wifi: iwlwifi: mvm: avoid NULL pointer dereference Date: Wed, 25 Sep 2024 07:51:10 -0400 Message-ID: <20240925115823.1303019-51-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240925115823.1303019-1-sashal@kernel.org> References: <20240925115823.1303019-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.10.11 Content-Transfer-Encoding: 8bit From: Miri Korenblit [ Upstream commit 557a6cd847645e667f3b362560bd7e7c09aac284 ] iwl_mvm_tx_skb_sta() and iwl_mvm_tx_mpdu() verify that the mvmvsta pointer is not NULL. It retrieves this pointer using iwl_mvm_sta_from_mac80211, which is dereferencing the ieee80211_sta pointer. If sta is NULL, iwl_mvm_sta_from_mac80211 will dereference a NULL pointer. Fix this by checking the sta pointer before retrieving the mvmsta from it. If sta is not NULL, then mvmsta isn't either. Signed-off-by: Miri Korenblit Reviewed-by: Johannes Berg Link: https://patch.msgid.link/20240825191257.880921ce23b7.I340052d70ab6d3410724ce955eb00da10e08188f@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 1d695ece93e9e..51c12d70e8c23 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c @@ -1195,6 +1195,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb, bool is_ampdu = false; int hdrlen; + if (WARN_ON_ONCE(!sta)) + return -1; + mvmsta = iwl_mvm_sta_from_mac80211(sta); fc = hdr->frame_control; hdrlen = ieee80211_hdrlen(fc); @@ -1202,9 +1205,6 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb, if (IWL_MVM_NON_TRANSMITTING_AP && ieee80211_is_probe_resp(fc)) return -1; - if (WARN_ON_ONCE(!mvmsta)) - return -1; - if (WARN_ON_ONCE(mvmsta->deflink.sta_id == IWL_MVM_INVALID_STA)) return -1; @@ -1335,7 +1335,7 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb, int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb, struct ieee80211_sta *sta) { - struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); + struct iwl_mvm_sta *mvmsta; struct ieee80211_tx_info info; struct sk_buff_head mpdus_skbs; struct ieee80211_vif *vif; @@ -1344,9 +1344,11 @@ int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb, struct sk_buff *orig_skb = skb; const u8 *addr3; - if (WARN_ON_ONCE(!mvmsta)) + if (WARN_ON_ONCE(!sta)) return -1; + mvmsta = iwl_mvm_sta_from_mac80211(sta); + if (WARN_ON_ONCE(mvmsta->deflink.sta_id == IWL_MVM_INVALID_STA)) return -1; -- 2.43.0