diff options
author | Kan Liang <kan.liang@intel.com> | 2016-11-15 13:40:10 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-11-16 03:46:35 -0500 |
commit | c499336cea8bbe15554c6fcea2138658c5395bfe (patch) | |
tree | 7ae5419d8309f8e61633778f513b131b15eba3f4 | |
parent | 864c2357ca898c6171fe5284f5ecc795c8ce27a8 (diff) |
perf/x86/uncore: Fix crash by removing bogus event_list[] handling for SNB client uncore IMC
Vince Weaver reported the following bug when KASAN is enabled:
[ 205.748005] BUG: KASAN: slab-out-of-bounds in snb_uncore_imc_event_del+0x6c/0xa0 at addr ffff8800caa43768
[ 205.758324] Read of size 8 by task perf_fuzzer/6618
It's caused by accessing box->event_list.
For client IMC, there are no generic counters. It defines its own fixed
free running counters. So event_list and n_events are unused.
They can be removed safely, which fixes the bug.
( There's still the separate question of how uninitialized state snuck into
this data structure - but that's a separate fix. )
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@kernel.org
Cc: davej@codemonkey.org.uk
Cc: dvyukov@google.com
Cc: eranian@gmail.com
Link: http://lkml.kernel.org/r/1479235210-29090-1-git-send-email-kan.liang@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/events/intel/uncore_snb.c | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c index 81195cca7eae..a3dcc12bef4a 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) | |||
490 | 490 | ||
491 | snb_uncore_imc_event_start(event, 0); | 491 | snb_uncore_imc_event_start(event, 0); |
492 | 492 | ||
493 | box->n_events++; | ||
494 | |||
495 | return 0; | 493 | return 0; |
496 | } | 494 | } |
497 | 495 | ||
498 | static void snb_uncore_imc_event_del(struct perf_event *event, int flags) | 496 | static void snb_uncore_imc_event_del(struct perf_event *event, int flags) |
499 | { | 497 | { |
500 | struct intel_uncore_box *box = uncore_event_to_box(event); | ||
501 | int i; | ||
502 | |||
503 | snb_uncore_imc_event_stop(event, PERF_EF_UPDATE); | 498 | snb_uncore_imc_event_stop(event, PERF_EF_UPDATE); |
504 | |||
505 | for (i = 0; i < box->n_events; i++) { | ||
506 | if (event == box->event_list[i]) { | ||
507 | --box->n_events; | ||
508 | break; | ||
509 | } | ||
510 | } | ||
511 | } | 499 | } |
512 | 500 | ||
513 | int snb_pci2phy_map_init(int devid) | 501 | int snb_pci2phy_map_init(int devid) |