From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1A10EB64DC for ; Sun, 9 Jul 2023 15:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbjGIP2h (ORCPT ); Sun, 9 Jul 2023 11:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234003AbjGIP2B (ORCPT ); Sun, 9 Jul 2023 11:28:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21A152705; Sun, 9 Jul 2023 08:25:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1E07860C17; Sun, 9 Jul 2023 15:16:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B9EAC433C7; Sun, 9 Jul 2023 15:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688915771; bh=+ARJS2fRf3jq6v4YN1dAH/bW3KjrxUoS3Vmx7GvoMn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orD2q+19KYLSiW+giGtlkUveOpIN2bx6LEK0VwpvBKP3UL3YBsWPyGmiHZGN995sp KNMJkkOWLOAYgGAXT4+g5Wk9j3kTyJyAx3tB9kVSSbxkf/QKeamfmcUeyf5gnnu/mw XDEBeirEoAW5Ix72Dydzhdf8rlBqXFuMCRwt0Od+4jnx/F2f++OI7Chnj8gRfz1NCX jVWt3ozhUnPwzQZfGq8JmobqiXauQRNFu6NXuqXCUTnmnCrFMhr6ABx8jTRG/PqsNV 6eg7TNaB1gmDrOYbsY+RI18L3OIASGlgJRup27hTrIjM8vJHc0sMTRUUIvKhxgLaTH FLPVnbYkeAc/A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , Roee Goldfiner , Gregory Greenman , Sasha Levin , kvalo@kernel.org, miriam.rachel.korenblit@intel.com, avraham.stern@intel.com, benjamin.berg@intel.com, jtornosm@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 6/7] wifi: iwlwifi: mvm: avoid baid size integer overflow Date: Sun, 9 Jul 2023 11:15:54 -0400 Message-Id: <20230709151555.513910-6-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230709151555.513910-1-sashal@kernel.org> References: <20230709151555.513910-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.186 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 1a528ab1da324d078ec60283c34c17848580df24 ] Roee reported various hard-to-debug crashes with pings in EHT aggregation scenarios. Enabling KASAN showed that we access the BAID allocation out of bounds, and looking at the code a bit shows that since the reorder buffer entry (struct iwl_mvm_reorder_buf_entry) is 128 bytes if debug such as lockdep is enabled, then staring from an agg size 512 we overflow the size calculation, and allocate a much smaller structure than we should, causing slab corruption once we initialize this. Fix this by simply using u32 instead of u16. Reported-by: Roee Goldfiner Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman Link: https://lore.kernel.org/r/20230620125813.f428c856030d.I2c2bb808e945adb71bc15f5b2bac2d8957ea90eb@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index 09f870c48a4f6..141581fa74c82 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -2590,7 +2590,7 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta, } if (iwl_mvm_has_new_rx_api(mvm) && start) { - u16 reorder_buf_size = buf_size * sizeof(baid_data->entries[0]); + u32 reorder_buf_size = buf_size * sizeof(baid_data->entries[0]); /* sparse doesn't like the __align() so don't check */ #ifndef __CHECKER__ -- 2.39.2