[lkml]   [2010]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] [180/223] perf_events: Fix perf_counter_mmap() hook in mprotect()
2.6.35-longterm review patch.  If anyone has any objections, please let me know.

From: Pekka Enberg <>

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

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

Reported-by: Dave Jones <>
Signed-off-by: Andi Kleen <>
Analyzed-by: Linus Torvalds <>
Cc: Ingo Molnar <>
Reviewed-by: Peter Zijlstra <>
Signed-off-by: Pekka Enberg <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Greg Kroah-Hartman <>

mm/mprotect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/mm/mprotect.c
--- linux.orig/mm/mprotect.c
+++ linux/mm/mprotect.c
@@ -211,6 +211,7 @@ success:
mmu_notifier_invalidate_range_end(mm, start, end);
vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
vm_stat_account(mm, newflags, vma->vm_file, nrpages);
+ perf_event_mmap(vma);
return 0;

@@ -299,7 +300,6 @@ SYSCALL_DEFINE3(mprotect, unsigned long,
error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
if (error)
goto out;
- perf_event_mmap(vma);
nstart = tmp;

if (nstart < prev->vm_end)

 \ /
  Last update: 2010-12-13 00:59    [from the cache]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site