From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbdHDAhp (ORCPT ); Thu, 3 Aug 2017 20:37:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:57256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbdHDAho (ORCPT ); Thu, 3 Aug 2017 20:37:44 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90AD622DA7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org MIME-Version: 1.0 In-Reply-To: <20170802173930.cstykcqefmqt7jau@hirez.programming.kicks-ass.net> References: <20170802173930.cstykcqefmqt7jau@hirez.programming.kicks-ass.net> From: Andy Lutomirski Date: Thu, 3 Aug 2017 17:37:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: perf: bug in rdpmc/mmap accounting after exec To: Peter Zijlstra Cc: Vince Weaver , "linux-kernel@vger.kernel.org" , Andy Lutomirski , Ingo Molnar , Arnaldo Carvalho de Melo , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 2, 2017 at 10:39 AM, Peter Zijlstra wrote: > On Wed, Jul 26, 2017 at 03:39:01PM -0400, Vince Weaver wrote: >> Hello >> >> so one last bug found by the PAPI testsuite. >> >> This one involves the rdpmc auto-disable on last unmap of an event >> feature. >> >> Failing test case: >> >> fd=perf_event_open(); >> addr=mmap(fd); >> exec() // without closing or unmapping the event >> fd=perf_event_open(); >> addr=mmap(fd); >> rdpmc() // GPFs due to rdpmc being disabled >> >> I won't pretend to be able to follow the rdpmc disabling code, but if I >> add some printks it looks like >> current->mm->context.perf_rdpmc_allowed >> isn't properly being reset on exec? >> >> In fact, current->mm->context.perf_rdpmc_allowed goes negative which seems >> like it shouldn't happen? >> >> Anyway, a test case for this can be found in the perf_event_tests, >> tests/rdpmc/rdpmc_exec_papi > > Good find that... > > The below seems to fix that for me. > ...because execve plays funny games with non-current mms. Whoops. Reviewed-by: Andy Lutomirski Can you send it upstream and tag it for stable?