]> git.baikalelectronics.ru Git - kernel.git/commit
perf/x86: Fix RDPMC vs. mm_struct tracking
authorPeter Zijlstra <peterz@infradead.org>
Wed, 2 Aug 2017 17:39:30 +0000 (19:39 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 10 Aug 2017 10:01:08 +0000 (12:01 +0200)
commit6f52601ce8e26e98bde5180a974f36d8fbe4805e
tree394e91ef850a8f2ca7091df66f679d8ac08195c6
parentd72f56560e645b139c9b2bf536c302261ee14c23
perf/x86: Fix RDPMC vs. mm_struct tracking

Vince reported the following rdpmc() testcase failure:

 > 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

The problem is of course that exec() plays tricks with what is
current->mm, only destroying the old mappings after having
installed the new mm.

Fix this confusion by passing along vma->vm_mm instead of relying on
current->mm.

Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Fixes: 69af0ed65652 ("perf: Add pmu callbacks to track event mapping and unmapping")
Link: http://lkml.kernel.org/r/20170802173930.cstykcqefmqt7jau@hirez.programming.kicks-ass.net
[ Minor cleanups. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/events/core.c
include/linux/perf_event.h
kernel/events/core.c