Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp430862ybm; Thu, 28 May 2020 06:32:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfP7fyG5iMZAuISY+d2AWDCghhwCMIQxaZqjwyF9mtWyLfydldJ2sqKDyqIMTbDPZ0hl7J X-Received: by 2002:a50:e444:: with SMTP id e4mr3015579edm.191.1590672763242; Thu, 28 May 2020 06:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590672763; cv=none; d=google.com; s=arc-20160816; b=pO7pEW8MIzyACvHQhMciqXwO+u2KvR5jFIK4gq45N68I5ls3yNTRMRfYV4vKBgmoYM YwZB5iOC7dqsNseaurHGaC65BcNvR8+QmNtaWF99AWTlv4qwHY66Hx2XibiVjjUpQVpJ rAXkl635lgm83Su7u0JIIJP9KgVkNxk5CqJxAjl+BLsZZP+6rJSbubrYoSHSCT2XbLKb vHUDWO5TJksy8UaysBwDdod6AIn/Il2XFdiD7O4CaiOOPiCx10wRqtRQnDSMyc/sHcjv C591YpcV/S5jgaEk1QeqXuYaaWvIWxcFjP8htKK8mT4omUBntBT9+2YUUT6rvVPodSg9 P7ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=4dGMikEF7zOypqbYFYrl0pX+vPOFc1m/erlOXqzsscE=; b=jNm5R7Dfu+5yMJi0g0+3OCFAdWocbKeyFdTVpEVzB9lEPQ+hOuDaT1h+p+t0rHW+gG EU/9GKxv4pLwsnB4E/zcC8bQcjwEvjYMXTMB1SrF3c607X9/LtjE9aaog4slLoJlpA/2 eY5scp8JokaVYinfQKf2B7wSJioOcMsx7g2ZMdJCVjveUE3f5iTlw51aNGN8zHCMkfIu iOz5saP9VO7sy+eBk5GYQmL6ZQ8KwpAh/4AJgpQTA6a6UoPqlfuU9Rq6DIttBT58T8k6 1Uw5mMAhBdlmbTYdMvNYm0h+0jiyuVxElZ9b6nlOe/k3BxNK1JOzfvdzbPvOcs5tSW20 Ll4g== 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 cf24si1489740ejb.80.2020.05.28.06.32.18; Thu, 28 May 2020 06:32:43 -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 S2390336AbgE1NaP (ORCPT + 99 others); Thu, 28 May 2020 09:30:15 -0400 Received: from mga02.intel.com ([134.134.136.20]:55917 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390320AbgE1NaL (ORCPT ); Thu, 28 May 2020 09:30:11 -0400 IronPort-SDR: JXCig5xqm0WyaJOrh98bp3e8I02OUIZ+Ei8U8f09qcMat/PtVX8deBa0azdF1JW6dPTl8Xrppv 0brzmcJm1oaw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 06:30:09 -0700 IronPort-SDR: yNgQRpzQQeWDsH7IIzyPbJXyHNFd1T1Ev6FEDI/mHl5BzWeZN2kEA2GuugDe9OVJjnJE28bFxe JyTiQM9WhHtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="302813677" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.21]) by orsmga008.jf.intel.com with ESMTP; 28 May 2020 06:30:08 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id E4E26301C5F; Thu, 28 May 2020 06:30:08 -0700 (PDT) Date: Thu, 28 May 2020 06:30:08 -0700 From: Andi Kleen To: kan.liang@linux.intel.com Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, David.Laight@aculab.com Subject: Re: [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing Message-ID: <20200528133008.GH611145@tassilo.jf.intel.com> References: <1590671727-99311-1-git-send-email-kan.liang@linux.intel.com> <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -Andi