From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934752AbcIFOpK (ORCPT ); Tue, 6 Sep 2016 10:45:10 -0400 Received: from mail.kernel.org ([198.145.29.136]:38932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934511AbcIFOok (ORCPT ); Tue, 6 Sep 2016 10:44:40 -0400 Date: Tue, 6 Sep 2016 11:44:34 -0300 From: Arnaldo Carvalho de Melo To: Peter Zijlstra Cc: Dmitry Vyukov , Ingo Molnar , Alexander Shishkin , Thomas Gleixner , "H. Peter Anvin" , "x86@kernel.org" , LKML Subject: Re: perf: out-of-bounds write in perf_callchain_store Message-ID: <20160906144434.GB11557@kernel.org> References: <20160906143608.GF3318@worktop.controleur.wifipass.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160906143608.GF3318@worktop.controleur.wifipass.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Sep 06, 2016 at 04:36:08PM +0200, Peter Zijlstra escreveu: > On Tue, Sep 06, 2016 at 03:42:40PM +0200, Dmitry Vyukov wrote: > > Hello, > > > > The following program trigger an out-of-bounds write in > > perf_callchain_store (if run in a parallel loop): > > > > https://gist.githubusercontent.com/dvyukov/c05d883e776a353a1d063b670f50bde6/raw/1c8906b1aacfbd8a0cc0b5cf0cc4d0535345e497/gistfile1.txt > > > > > > BUG: KASAN: slab-out-of-bounds in perf_callchain_user+0xe65/0xfc0 at > > addr ffff88003e162840 > > Write of size 8 by task syz-executor/22516 > > CPU: 0 PID: 22516 Comm: syz-executor Not tainted 4.8.0-rc5-next-20160905+ #14 > > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > > ffffffff886b6fe0 ffff88003ec07738 ffffffff82db81a9 ffffffff00000000 > > fffffbfff10d6dfc ffff88003e800a00 ffff88003e161740 ffff88003e163740 > > 0000000000000001 ffff88003e162840 ffff88003ec07760 ffffffff8180b2ec > > Call Trace: > > [] __asan_report_store8_noabort+0x17/0x20 > > mm/kasan/report.c:332 > > [< inline >] perf_callchain_store include/linux/perf_event.h:1146 > > [] perf_callchain_user+0xe65/0xfc0 arch/x86/events/core.c:2441 > > [] get_perf_callchain+0x448/0x680 kernel/events/callchain.c:235 > > [] perf_callchain+0x14d/0x1a0 kernel/events/callchain.c:191 > > Urgh, that callchain code is a pain with that context/entries > separation. But I can't see an obvious overrun there. > > But WTF is max_contexts a sysctl? that doesn't seen to make any kind of > sense. > > Acme, can you untangle that stuff and spot the fail? I looked at it briefly some moments ago, couldn't find it so far, have to look at what was behind adding a sysctl for that :-\ And yeah, that entry/ctx thing, IIRC, was done to reduce patch size, probably needs some polishing to become clearer. - Arnaldo