Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7565535rwd; Tue, 20 Jun 2023 03:08:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ATGl2Bdygk4vbpW3yuX7YOdgxqsGzaIbIX0YRk+4ELbpXY/94+pmALEd6rd0MMHDv2xtP X-Received: by 2002:a17:90b:4fc2:b0:260:d8c0:ae79 with SMTP id qa2-20020a17090b4fc200b00260d8c0ae79mr250678pjb.35.1687255719161; Tue, 20 Jun 2023 03:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687255719; cv=none; d=google.com; s=arc-20160816; b=SvBp4mFh3Sv83K3DjgtaCzYaMjAgzzzzYjRPrj6Uz8ZvEukWCklbASi4SGGXwWPLN0 3HGv/PPQkesIhX3bNejxXkr7Ai6qET8+FAMRrGkcKrmdscWqhdimpYkTXdrT2JAFUzBL e/chpULHfGYCRKhL0HCyOd5sta/B5VcRYpPSV0d87V502YFI+57pXFHJZmnlXU4cKhZ+ 6iduMJy9HWQwFghW/FSqkY4K4WJxdY4bTG8yrPv7Fn+GDrVn3cBjnpyK9Ir1a8xyYSav +8mLU5hQSj/XrIgSHA+DrxPQ5X97ctl3esmo6gDZXpf0Lp/byppkUFLzdp/I0oVzFi4Y 5V7Q== 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=2zSF6vLUTZUk+iN9SuouvxpEwoHxpd8T5S13dfxw7Qc=; b=zqofBqFj0gsXM5QZ8n+Odo7F5qdLcItAIePdXZEWrAstC+J5+ehOSp9LkffQ1+Az4U rQLfZIDy4t0KW01y9ipk9ICsKBNaI2fYMREj06e4DCkixeu/22X9G+gBd+YwH873OHYX pQsEolToGSO9Q71xgyBjXaAppEMyiF/6Y8v3vrlesY/zU8hyocIU9HLeu2xvbJaYsf8y 3HNXXMuIJ+fxc0/Fp1iWGYAmpUKgLXJUP/0SSm7zxXgYQc+hcJnMPE1sCJ0Wv/O8YvG3 IJp+ySv/sNeszW9pTJYJHnhrGFUWbrEZL+7jBuCTXxO6+Nvpue3m8ZYBT5Ev0GjJCLWY 3iQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VW4zKmKN; 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 j7-20020a17090a31c700b002508889985fsi8945298pjf.95.2023.06.20.03.08.29; Tue, 20 Jun 2023 03:08:39 -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=VW4zKmKN; 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 S231320AbjFTKFX (ORCPT + 59 others); Tue, 20 Jun 2023 06:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbjFTKE6 (ORCPT ); Tue, 20 Jun 2023 06:04:58 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B46C118 for ; Tue, 20 Jun 2023 03:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687255497; x=1718791497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ggwMVEJ0/oSmkoPg6/+Le0nDMhajGjBs67w+Nlcx8zU=; b=VW4zKmKNHJ5/CEvGtYDRm5ONndIzjSXtD7ODX7E6/IY96rvOMuCRlGz+ z4sBOCIqEykEMR5nSgrzHHbeJsMNCwGP7zOqCDWxtwXOFbgfvuW3Cxswz mTcM1a9nFxeblgyZ1WcK6JGUGCuZih720UwzoeCz+e4C/VZLr7ElNIvSc X+R70W5QhSUCv5a3XAYFmnJL5A+cVwP7Q4AuLBIc+icZLR2XLh15/LHpJ +yB8/LseDlzzJunViVqtoZJX3zwzZWeg9m5Ee9wLXK0TibiY2lBVm2lWw 2bHRzWpLaVVYArpA0Cutdt20VFYr+YqCbXEx3zOe5sq+YHvunIwOFMBQE A==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="359819660" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="359819660" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 03:04:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="838143576" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="838143576" Received: from rafist-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.intel.com) ([10.214.208.68]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 03:04:55 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Roee Goldfiner , Gregory Greenman Subject: [PATCH 16/19] wifi: iwlwifi: mvm: avoid baid size integer overflow Date: Tue, 20 Jun 2023 13:04:02 +0300 Message-Id: <20230620125813.f428c856030d.I2c2bb808e945adb71bc15f5b2bac2d8957ea90eb@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230620100405.45117-1-gregory.greenman@intel.com> References: <20230620100405.45117-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, 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: Johannes Berg 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 --- 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 37a52ffa8897..3b9a343d4f67 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -2885,7 +2885,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.38.1