Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7564324rwd; Tue, 20 Jun 2023 03:07:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6za3KFHPhgVlQ5CxV9LVcNLPUBLn4ZyVQBQXCUqcZg2vxEqneUrBI/CLK32LvTwr3cvBvG X-Received: by 2002:a05:6830:22c1:b0:6aa:ecb5:f186 with SMTP id q1-20020a05683022c100b006aaecb5f186mr10633210otc.7.1687255651115; Tue, 20 Jun 2023 03:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687255651; cv=none; d=google.com; s=arc-20160816; b=brcxKUOSqfoYktJe2JYKFrD2KaEVAegwrTeKQPbT2g76MwAgMii+QZhgG3cpBkJtuB tgLS4Bj/l4iCHzgJZLX0v/2x9WREM1MYNbLrxQdX2OK8+bNhCds1APNQx3WuHm42+oFs FCdYciujJQ0UbjV6CKIBi/SczJ2faIAAjORifGMvRZBcGKzeAMrCGsc5Z6e0AZQ/ON6m da8ab+e5jFpZaqk6nMQ1kTE3vCSYa2YeKaIYFTrvklrRCbwutQzVvdgo1qgau2rMixxp RPrT43U+/YhSNUDTuDw4nNNk38gjVju/LHyVlEzDUCYpExPD6TxK8VCW83SzJ6v3I5fI K9xQ== 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=QE8hhQerujl2PDEo86NsU1/vFmOmcJo1Vg/vqro6PgU=; b=Wp+msO6XfjsPq4TzwYnHaNBpoEi+rBHrYATELVyxpuSx6m0O90KWthg9o7p2ua5wLc JKj5HxXCDDj89ZtoMYrnXgs1dd9gP4zznxTR/8KdztTlum+vT0yzav7f59p/pCKLaFvp QCnVq/Ixh+sNt7A4muQONO7vXbkqe3MOZDKZDHxhiz5lzPBqyjKaLpTDmIp+1RYvhnsL mb2iGDHe6FsC9NsehWdS/p6WxOYGebUpFwDl3eSmXUfENIsXDeaPnrgRCXh+phUYg8oA WbGVGVzQwjKd0rLHJUC/tH/40W+dVOjpd0DWkI6CdSCgds9xBPgB8qODA63nMq9Ei85q lurA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mVP3LIH+; 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 z19-20020a63e113000000b00553b02a9a1dsi1334160pgh.217.2023.06.20.03.07.22; Tue, 20 Jun 2023 03:07:31 -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=mVP3LIH+; 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 S231140AbjFTKFB (ORCPT + 59 others); Tue, 20 Jun 2023 06:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbjFTKEg (ORCPT ); Tue, 20 Jun 2023 06:04:36 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA14170A for ; Tue, 20 Jun 2023 03:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687255475; x=1718791475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xkc1CTFyJB127sT2X9YtR5meF92MSH89pGlRicmhgQc=; b=mVP3LIH+ELG8a4dmW7KKCD6UT2wegTMBL1WNoKVVylsFjT2aUlw1kQdU I1d1E7kBA3lXgWR7PuX+Zlam4WcvQaQIp2TgUjlmtvxhnJKF9i0cBw7yu e1DPfcsvs2bkAnoatRLbieeG4kMeL6VSUrj8e/M9qlv4SljWNsLCMiKD9 Xu3aG74Avq6vrO5z10S6kQEyS4GH80LHJhWJOI3S3LxPdnOl28Kh2GofR SPegQJ5QM/iSDk/HFK3nAIAx93Fp8TV15j1v2wBVxipF5arIuGS3kz8X4 98v1itg45Ecz/VyKQkHddvoGmK8yAruamum/SS3EWXsUN7LS80QOEnjKS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="359819525" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="359819525" 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:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="838142796" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="838142796" 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:21 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 02/19] wifi: iwlwifi: pcie: add size assertions Date: Tue, 20 Jun 2023 13:03:48 +0300 Message-Id: <20230620125813.8f54f2990b92.If19a038dfd633d4601e3d44dd0ff678bc0a851e9@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 Ensure that the TX command scratch fits into the buffer provided by the first TB. It does, of course, but add some build-time validations in case we touch this code. Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 5 ++++- drivers/net/wireless/intel/iwlwifi/queue/tx.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c index 3546c5269c3b..1337fa95f657 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* - * Copyright (C) 2003-2014, 2018-2021 Intel Corporation + * Copyright (C) 2003-2014, 2018-2021, 2023 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */ @@ -1547,6 +1547,9 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, /* there must be data left over for TB1 or this code must be changed */ BUILD_BUG_ON(sizeof(struct iwl_tx_cmd) < IWL_FIRST_TB_SIZE); + BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + + offsetofend(struct iwl_tx_cmd, scratch) > + IWL_FIRST_TB_SIZE); /* map the data for TB1 */ tb1_addr = ((u8 *)&dev_cmd->hdr) + IWL_FIRST_TB_SIZE; diff --git a/drivers/net/wireless/intel/iwlwifi/queue/tx.c b/drivers/net/wireless/intel/iwlwifi/queue/tx.c index 245bff01b4f8..fbacbe9ada15 100644 --- a/drivers/net/wireless/intel/iwlwifi/queue/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/queue/tx.c @@ -648,6 +648,13 @@ struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans, /* There must be data left over for TB1 or this code must be changed */ BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen2) < IWL_FIRST_TB_SIZE); + BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + + offsetofend(struct iwl_tx_cmd_gen2, dram_info) > + IWL_FIRST_TB_SIZE); + BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen3) < IWL_FIRST_TB_SIZE); + BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + + offsetofend(struct iwl_tx_cmd_gen3, dram_info) > + IWL_FIRST_TB_SIZE); memset(tfd, 0, sizeof(*tfd)); -- 2.38.1