Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11455179rwd; Thu, 22 Jun 2023 13:34:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oyTG/4Rs/oGqlcSXlMMOFvphshf4YDEdst9I/LWzQNx1N8wXCsrrdjsBbr/EIQnSoInAu X-Received: by 2002:a05:6a20:3d09:b0:123:a604:df73 with SMTP id y9-20020a056a203d0900b00123a604df73mr5123702pzi.30.1687466068877; Thu, 22 Jun 2023 13:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687466068; cv=none; d=google.com; s=arc-20160816; b=ABEM0JOZ2oTqxf6jeF1Cu46ztRRcqB2Xzlq2qGeTG989Elw3xqw/I3TNpF66bE+tq6 g+rOZn+Y3ylDnoXkUYD+Rm4Y9Rdts0wpTgZTmFbE6GOL/BwJ2+b1cdM2gjgZz2l4QITF 4IE5v1FemO0Mj7PGbtKzBQ1CktiPEkzBcyhhjbqG6Pov0M5lmhuHYp/tVOz/diUuvfK3 qga7GsEBjuu6iy+YAQbeNOrEVTUoVWaXk0DM6nKoLbvDWnearhGI34RleZDkGuXgq9LK MWDq9SoQ7YVh14xv8fl4KOvZ/QuC80TrtPGmZzr//Jc6h47rqinLEQNJITL+QIAfkxI8 /CAw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=vNAizPVFd5LRn8066CIuyYGEG5jZlVPU8n7cGc953+8=; b=V7UNjLS8BDkX8xGguB+RkxYnUzTvYwOKRTrXGW6uh3EdDrqgG+aOVGXRDHyQJXRWsU 2JebJrpxRNAF4D/hc8f75lZ3R+p+E1xFhRJ1OqV0wUUn7uOuk+n06dGopRDNJewrEWFt iuVZJCoP5V7tKG1KEbmvITBPmZ8s4nhoR1KZHstOr7Jswn2mhoaI+iGD444C2+Gj+pRP 0juU3AOTTlT/8b+pQxPnQsFDSmToxnxSVVp5/Yg5xi+en5kbiEmx2yYHbdzoYwW4G9zq 4uQAlF6Ig/3NnGIxyveOLLGw9TPaaPFhB5vF0tYVzd7webjqbaGvZR17KhfFwx3fpKDe Q10A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P+4zkcKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 l17-20020a637011000000b0054fd9e9b862si7201060pgc.232.2023.06.22.13.34.15; Thu, 22 Jun 2023 13:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=P+4zkcKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S230379AbjFVT5t (ORCPT + 99 others); Thu, 22 Jun 2023 15:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjFVT5r (ORCPT ); Thu, 22 Jun 2023 15:57:47 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7131D1BF0; Thu, 22 Jun 2023 12:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687463866; x=1718999866; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BgpRqo4puNcohYTMFAWxOVTW7DldqwzOBNgi36hCvWc=; b=P+4zkcKWB/q9HpxDCd/eRNI94SwcTW4jBesvOHLqgF+3O4tjxqD4+PoS CMGM2gffjr3xuYVZZWC2ioDvfWtLlBCAqpQsPcn+DG5OI0aXsyrpZKJKy da9b+lyJA2v+t82VmEZReO/S2sWvvEfRnxdsVpTv4c8bB3/TRycS8UMVG CTzTpp6b4aNnLLt6iO9ISU3LDiupbsEiRCtrB/z785+YvVtkE2ALMJU7h 2mkMBHwTIeiJsL7xUzK78+7wt+NplIqbCGsaM2BqcdTVOM/zquRZf2utI X5lZBY0YdkCYOoSu271+khdf1VqK7bUTOZl+1uFYJUSgwBI9UzaeBasbK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="358088608" X-IronPort-AV: E=Sophos;i="6.01,149,1684825200"; d="scan'208";a="358088608" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 12:57:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="889204563" X-IronPort-AV: E=Sophos;i="6.01,149,1684825200"; d="scan'208";a="889204563" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga005.jf.intel.com with ESMTP; 22 Jun 2023 12:57:28 -0700 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH] platform/x86/intel/tpmi: Prevent overflow for cap_offset Date: Thu, 22 Jun 2023 12:57:17 -0700 Message-Id: <20230622195717.3125088-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org cap_offset is a u16 field, so multiplying with TPMI_CAP_OFFSET_UNIT (which is equal to 1024) to covert to bytes will cause overflow. This will be a problem once more TPMI features are added. This field is not used except for calculating pfs->vsec_offset. So, leave cap_offset field unchanged and multiply with TPMI_CAP_OFFSET_UNIT while calculating pfs->vsec_offset. Signed-off-by: Srinivas Pandruvada --- Rebased on top of https://kernel.googlesource.com/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 review-hans drivers/platform/x86/intel/tpmi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c index 9c606ee2030c..d1fd6e69401c 100644 --- a/drivers/platform/x86/intel/tpmi.c +++ b/drivers/platform/x86/intel/tpmi.c @@ -356,9 +356,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev) if (!pfs_start) pfs_start = res_start; - pfs->pfs_header.cap_offset *= TPMI_CAP_OFFSET_UNIT; - - pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset; + pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset * TPMI_CAP_OFFSET_UNIT; /* * Process TPMI_INFO to get PCI device to CPU package ID. -- 2.38.1