]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commit
perf_events: Fix perf_counter_mmap() hook in mprotect()
authorPekka Enberg <penberg@kernel.org>
Mon, 8 Nov 2010 19:29:07 +0000 (21:29 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Dec 2010 21:33:19 +0000 (13:33 -0800)
commit32c0a63f763003ff9cba775f45211af135f2f1f2
tree234dbe02f4a6968c35a8140728e0f0bc16d0338c
parent5c4790d515ed8ec5dbc8e2b195e47ae27e7177ea
perf_events: Fix perf_counter_mmap() hook in mprotect()

commit 63bfd7384b119409685a17d5c58f0b56e5dc03da upstream.

As pointed out by Linus, commit dab5855 ("perf_counter: Add mmap event hooks to
mprotect()") is fundamentally wrong as mprotect_fixup() can free 'vma' due to
merging. Fix the problem by moving perf_event_mmap() hook to
mprotect_fixup().

Note: there's another successful return path from mprotect_fixup() if old
flags equal to new flags. We don't, however, need to call
perf_event_mmap() there because 'perf' already knows the VMA is
executable.

Reported-by: Dave Jones <davej@redhat.com>
Analyzed-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Reviewed-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/mprotect.c