Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp442040ybm; Thu, 28 May 2020 06:49:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyAFDo5yFSbqiPOwe4sTcx530BKgCbJBbEMzY0tkRGAQnpE2KhRRER0jq1pmhlY8a4QNz+ X-Received: by 2002:a50:ee8f:: with SMTP id f15mr3271207edr.168.1590673758963; Thu, 28 May 2020 06:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590673758; cv=none; d=google.com; s=arc-20160816; b=OXBH89MEbmyKGZbsBTcBMMp7ajNWzR4R6PuCU82CJWx1onc1Bdve5nstlKzesU89E+ dakmTeFZij195DF1D+NLXlCMnK1yuWncP/gA7cr1GRbZX67k4Mk540EnLmmZNAjHyQid HxnTr/ktcqtnVTEzWyoYr7P/uob2UDZi2jHPZFQ26cZNZzsQ0izKiV78fTsEr/eS2oTX RMsq+Sv88rmCj7PVzNQL0ZGavB4gQ/x+x3Vg9PQI54XextwnPh0tLLnC02kNip/cdCHb Gz4Q1aTDZH5D0PebSVrfuBO7hsMb0ycFu6uO4IGiHdlzorRfhQAg+VWrv0BfDos6aBvN uENA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=p+6Fiqy1jxEBH6K2Ozmytvo8131jdkyHPVeKOQ//V80=; b=DbUItNpOkivDRR0A6SiTAMNxZBY3OZKq2Wehfh31mB8p4EKd3MQigrsaU/YyRCUdDs STMvTWdO110yTbULQD2bjvTFT7r1EPxYJKS99vWASGi2YXDEdVJO5Bl2VF7sLn4/+sF6 wl1upGCPecaL6LSgdRcxLAohCn0aQf+8XCJntOYjyoHZOlu3WH5uTtfYAT1OKnSCoTM1 zl+9J6e+vCQlSCRh8X2nvRlxiTDzSk3by/pNikymwy9ggdHw+0+S4h3LCf0ScvhyEXhh 28rQqCAek6ZZzNPciJrTgTA7F5gZ3nVDys7L6W1Kbe7LHSkVqu9YE/DgB5691nlyyY/r lygQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si3968640ejs.406.2020.05.28.06.48.55; Thu, 28 May 2020 06:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390558AbgE1Nqq (ORCPT + 99 others); Thu, 28 May 2020 09:46:46 -0400 Received: from mga12.intel.com ([192.55.52.136]:45762 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390486AbgE1Nqp (ORCPT ); Thu, 28 May 2020 09:46:45 -0400 IronPort-SDR: npT3tUtQIe4jSIxpmT52vyFPUx2UxSB3Qybe3uMt502qVZU/XryZHVgjVCNTnokr9Tu6FCD7IH OUZ4IetSx5zg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 06:46:44 -0700 IronPort-SDR: OcAbiyyG/qrTRK8vKeoK7Nfvn2wQ4Q/svmoglcme+HUxD21WAW76eipKWK6maq0/JXJ1b2rkoK skAbXoyIsYpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="255789532" Received: from linux.intel.com ([10.54.29.200]) by fmsmga007.fm.intel.com with ESMTP; 28 May 2020 06:46:44 -0700 Received: from [10.251.9.11] (kliang2-mobl.ccr.corp.intel.com [10.251.9.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id D2179580785; Thu, 28 May 2020 06:46:43 -0700 (PDT) Subject: Re: [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing To: Andi Kleen Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, David.Laight@aculab.com References: <1590671727-99311-1-git-send-email-kan.liang@linux.intel.com> <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> <20200528133008.GH611145@tassilo.jf.intel.com> From: "Liang, Kan" Message-ID: <4f804e10-97c0-9861-4131-b33ca977d2eb@linux.intel.com> Date: Thu, 28 May 2020 09:46:42 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200528133008.GH611145@tassilo.jf.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/2020 9:30 AM, Andi Kleen wrote: > On Thu, May 28, 2020 at 06:15:27AM -0700, kan.liang@linux.intel.com wrote: >> From: Kan Liang >> >> An oops will be triggered, if perf tries to access an invalid address >> which exceeds the mapped area. >> >> Check the address before the actual access to MMIO sapce of an uncore >> unit. > > Ah ok the range check is here > >> >> Suggested-by: David Laight >> Signed-off-by: Kan Liang >> --- >> arch/x86/events/intel/uncore.c | 3 +++ >> arch/x86/events/intel/uncore.h | 12 ++++++++++++ >> arch/x86/events/intel/uncore_snbep.c | 6 ++++++ >> 3 files changed, 21 insertions(+) >> >> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c >> index cf76d66..284f8e7 100644 >> --- a/arch/x86/events/intel/uncore.c >> +++ b/arch/x86/events/intel/uncore.c >> @@ -132,6 +132,9 @@ u64 uncore_mmio_read_counter(struct intel_uncore_box *box, >> if (!box->io_addr) >> return 0; >> >> + if (!is_valid_mmio_offset(box, event->hw.event_base)) >> + return 0; > > Is this function used somewhere else? Otherwise it should be added > together with its users. > Yes, it's generic function. Current MMIO uncore units invoke it to read counter. Thanks, Kan