Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp432681ybm; Thu, 28 May 2020 06:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytwb4pIB4HvmCt1MQEyQGfSeBEFQVVZv1w53bIjDuhPBfKN90mD83JbTBHnogUCsRQfvA1 X-Received: by 2002:aa7:db4c:: with SMTP id n12mr3042996edt.99.1590672918177; Thu, 28 May 2020 06:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590672918; cv=none; d=google.com; s=arc-20160816; b=VEPJ9H4AChbSmLh/8eg/baEHoHmt/Wt6WnvKwyr7sJatyuesb4n5oMVJnfKP0rcVrB dpJ5CVAtqSCp2nXCAYUcflgCOlnxrogn2jQBssGl8Xb/22c4vwZztzvd7fvGSTkuYLQT 6D1xC1f5hLU5cbyE/N1suhtdbiIzhVsdHxHEJlDuWXZituHa5namDbHzZObhs/W42p3C 87dQSS+tf36p+BuFZyw3rz0dj2iD2jBGSH2IA18hM5HweUIZCX+7Nh4iHXJV1C7Utuxj tCaAK896AfdNObLdKNhQgBQOYcRTseDsbuW8hgvuBPm1TOv+N8otWKuMek6PXf1t4YPj BxyA== 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:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=8kDUAJdXkW0UJ3bRsCRzurGMVtQgIsD0C61NPICCtM8=; b=u7wd2fQX39QXZimMsBTqPKlZvp68Bsq+4NiQh1um0iydiHO495r2/kPxJQS7YLTZbc NLknpcNvbq1YB631FhTEGC4Zn4sWnBS5hoBXaBPDhWyCX2zs21QQ40eiP8+Zr8/Caeij wJbs3orohkboR5S8+wU0usM431Pn/f8kUmmwm2MYFU/TnERDq6ek3+8xj2ki96JHAHUi iS8bpTzsAo0OHg7+fIlpsjXsXbE0hLlc9pLpXxGVfCAxT5Bqofj7TkQ3OZ+0wLzIcZId kf+f2Od47CCHb1JU6wUAU2X2nkml5dTznJObW7+3SdbmuaSJeE3Hz8S5x0QfdO5PtzoW YPTQ== 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=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si498039edz.261.2020.05.28.06.34.54; Thu, 28 May 2020 06:35: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=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390441AbgE1NdH convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 May 2020 09:33:07 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:43498 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390303AbgE1NdF (ORCPT ); Thu, 28 May 2020 09:33:05 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-168-oXXW1TqjM1ui_dIee1C0Zw-1; Thu, 28 May 2020 14:33:01 +0100 X-MC-Unique: oXXW1TqjM1ui_dIee1C0Zw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 28 May 2020 14:33:00 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 28 May 2020 14:33:00 +0100 From: David Laight To: "'kan.liang@linux.intel.com'" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" CC: "ak@linux.intel.com" Subject: RE: [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing Thread-Topic: [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing Thread-Index: AQHWNPJS+Ezh9RvMC0GYZtjdLUC73Ki9fXeg Date: Thu, 28 May 2020 13:33:00 +0000 Message-ID: References: <1590671727-99311-1-git-send-email-kan.liang@linux.intel.com> <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> In-Reply-To: <1590671727-99311-3-git-send-email-kan.liang@linux.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kan.liang@linux.intel.com > Sent: 28 May 2020 14:15 ... > +static inline bool is_valid_mmio_offset(struct intel_uncore_box *box, > + unsigned long offset) You need a better name, needs to start 'uncore_' and 'mmio' probably isn't right either. > +{ > + if (box->pmu->type->mmio_map_size > offset) > + return true; Swap over. Conditionals always read best if 'variable op constant'. So you want: if (offset < box->pmu->type->mmio_map_size) return true; > + > + pr_warn_once("perf uncore: Access invalid address of %s.\n", > + box->pmu->type->name); Pretty hard to debug without the invalid offset. I've no idea what the code is supposed to be doing though. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)