public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Andi Kleen <ak@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
Date: Thu, 28 May 2020 09:46:42 -0400	[thread overview]
Message-ID: <4f804e10-97c0-9861-4131-b33ca977d2eb@linux.intel.com> (raw)
In-Reply-To: <20200528133008.GH611145@tassilo.jf.intel.com>



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 <kan.liang@linux.intel.com>
>>
>> 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 <David.Laight@ACULAB.COM>
>> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>> ---
>>   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

  reply	other threads:[~2020-05-28 13:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 13:15 [PATCH V2 1/3] perf/x86/intel/uncore: Fix oops when counting IMC uncore events on some TGL kan.liang
2020-05-28 13:15 ` [PATCH V2 2/3] perf/x86/intel/uncore: Record the size of mapped area kan.liang
2020-05-28 13:29   ` Andi Kleen
2020-05-28 13:44     ` Liang, Kan
2020-05-28 13:15 ` [PATCH V2 3/3] perf/x86/intel/uncore: Validate MMIO address before accessing kan.liang
2020-05-28 13:30   ` Andi Kleen
2020-05-28 13:46     ` Liang, Kan [this message]
2020-05-28 13:33   ` David Laight
2020-05-28 13:49     ` Liang, Kan
2020-05-28 14:02       ` Andi Kleen
2020-05-28 14:08         ` Liang, Kan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f804e10-97c0-9861-4131-b33ca977d2eb@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=David.Laight@aculab.com \
    --cc=ak@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox