From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752412AbdLFPqP (ORCPT ); Wed, 6 Dec 2017 10:46:15 -0500 Received: from merlin.infradead.org ([205.233.59.134]:56060 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196AbdLFPqM (ORCPT ); Wed, 6 Dec 2017 10:46:12 -0500 Date: Wed, 6 Dec 2017 16:45:44 +0100 From: Peter Zijlstra To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Fengguang Wu , linux-kernel@vger.kernel.org, Wang Nan , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Linus Torvalds , Will Deacon , lkp@01.org, Dmitry Vyukov , kasan-dev@googlegroups.com, kernel-team@lge.com Subject: Re: BUG: KASAN: slab-out-of-bounds in perf_callchain_user+0x494/0x530 Message-ID: <20171206154544.oiavdgfrpryak23z@hirez.programming.kicks-ass.net> References: <20171130023218.g2y35nn4zyufqk6t@wfg-t540p.sh.intel.com> <20171130082026.ih7esfpn4wfsfoge@hirez.programming.kicks-ass.net> <20171130193712.GU3298@kernel.org> <20171205081156.GB16663@sejong> <20171205133740.GA28405@kernel.org> <20171205144718.GA27916@danjae.aot.lge.com> <20171206134706.ahlr6ygnhtu2ik4s@hirez.programming.kicks-ass.net> <20171206143130.GA3367@danjae.aot.lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171206143130.GA3367@danjae.aot.lge.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 06, 2017 at 11:31:30PM +0900, Namhyung Kim wrote: > > There's also a race against put_callchain_buffers() there, consider: > > > > > > get_callchain_buffers() put_callchain_buffers() > > mutex_lock(); > > inc() > > dec_and_test() // false > > > > dec() // 0 > > > > > > And the buffers leak. > > Hmm.. did you mean that get_callchain_buffers() returns an error? Yes, get_callchain_buffers() fails, but while doing so it has a temporary increment on the count. > AFAICS it cannot fail when it sees count > 1 (and callchain_cpus_ > entries is allocated). It can with your patch. We only test event_max_stack against the sysctl after incrementing.