Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932985AbcKPIpc (ORCPT ); Wed, 16 Nov 2016 03:45:32 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33485 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751572AbcKPIp1 (ORCPT ); Wed, 16 Nov 2016 03:45:27 -0500 Date: Wed, 16 Nov 2016 09:45:23 +0100 From: Ingo Molnar To: kan.liang@intel.com Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, davej@codemonkey.org.uk, dvyukov@google.com, eranian@gmail.com, linux-kernel@vger.kernel.org, Vince Weaver , Stephane Eranian , Jiri Olsa Subject: Re: [PATCH] perf/x86/uncore: remove event_list for snb client uncore IMC Message-ID: <20161116084523.GA22045@gmail.com> References: <1479235210-29090-1-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479235210-29090-1-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1600 Lines: 53 * kan.liang@intel.com wrote: > From: Kan Liang > > A BUG was found by perf_fuzzer after enabled KASAN. > [ 205.748005] BUG: KASAN: slab-out-of-bounds in > snb_uncore_imc_event_del+0x6c/0xa0 at addr ffff8800caa43768 > Reported-by: Vince Weaver > Tested-by: Vince Weaver > Signed-off-by: Kan Liang > --- > arch/x86/events/intel/uncore_snb.c | 12 ------------ > 1 file changed, 12 deletions(-) > > diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c > index 81195cc..a3dcc12 100644 > --- a/arch/x86/events/intel/uncore_snb.c > +++ b/arch/x86/events/intel/uncore_snb.c > @@ -490,24 +490,12 @@ static int snb_uncore_imc_event_add(struct perf_event *event, int flags) > > snb_uncore_imc_event_start(event, 0); > > - box->n_events++; > - > return 0; > } > > static void snb_uncore_imc_event_del(struct perf_event *event, int flags) > { > - struct intel_uncore_box *box = uncore_event_to_box(event); > - int i; > - > snb_uncore_imc_event_stop(event, PERF_EF_UPDATE); > - > - for (i = 0; i < box->n_events; i++) { > - if (event == box->event_list[i]) { > - --box->n_events; > - break; > - } > - } I'll apply this fix - but could we please also make sure box->event_list[] _always_ get initialized to a sane state? If it had a proper zero initial value in box->n_events the bug would not have triggered. So struct intel_uncore_box initialization appears to be sloppy, and that should be looked at as well... Thanks, Ingo