Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753360AbcKRLk4 (ORCPT ); Fri, 18 Nov 2016 06:40:56 -0500 Received: from mga11.intel.com ([192.55.52.93]:7733 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751839AbcKRLky (ORCPT ); Fri, 18 Nov 2016 06:40:54 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,509,1473145200"; d="scan'208";a="6035569" From: Alexander Shishkin To: Vince Weaver , "linux-kernel\@vger.kernel.org" Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , "dvyukov\@google.com" Subject: Re: perf: fuzzer KASAN: global-out-of-bounds in match_token In-Reply-To: References: User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Fri, 18 Nov 2016 13:38:43 +0200 Message-ID: <877f81f264.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2104 Lines: 59 Vince Weaver writes: > On Thu, 17 Nov 2016, Vince Weaver wrote: > >> On Thu, 17 Nov 2016, Vince Weaver wrote: >> > > >> > > [ 911.507365] ================================================================== >> > > [ 911.514824] BUG: KASAN: global-out-of-bounds in match_token+0x268/0x310 at addr ffffffffb14ad058 >> > > [ 911.523912] Read of size 8 by task perf_fuzzer/20662 >> > > [ 911.528945] Address belongs to variable if_tokens+0x78/0xa0 > > I managed to create a short reproducer that reliably causes the issue on > my skylake test machine. Thanks a bunch, and ugh, this is embarrassing. >From 139306c3bcf7abf49c51a8e56131aaae51222594 Mon Sep 17 00:00:00 2001 From: Alexander Shishkin Date: Fri, 18 Nov 2016 13:24:55 +0200 Subject: [PATCH] perf: Fix address filter parser The token table passed into match_token() must be null-terminated, which it currently is not in the perf's address filter string parser, as caught by Vince's perf_fuzzer and KASAN. It doesn't blow up otherwise because of the alignment padding of the table to the next element in the .rodata, which is luck. Fixing by adding a null-terminator to the token table. Signed-off-by: Alexander Shishkin Fixes: 375637bc524 ("perf/core: Introduce address range filtering") Reported-by: Vince Weaver Cc: stable@vger.kernel.org # v4.7+ --- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index c6e47e97b3..63c72dee71 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8012,6 +8012,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event) * if is not specified, the range is treated as a single address. */ enum { + IF_ACT_NONE = -1, IF_ACT_FILTER, IF_ACT_START, IF_ACT_STOP, @@ -8035,6 +8036,7 @@ static const match_table_t if_tokens = { { IF_SRC_KERNEL, "%u/%u" }, { IF_SRC_FILEADDR, "%u@%s" }, { IF_SRC_KERNELADDR, "%u" }, + { IF_ACT_NONE, NULL }, }; /* -- 2.10.2