Skip to contentSkip to conversation

perf_counter: Allow mmap if paranoid checks are turned off

tip:perfcounters/core tip-bot for Ingo Molnar 1 participant 1 message Sep 15, 2009

lore
Share & tools
lore
#0 lore raw
Commit-ID:  459ec28ab404d7afcd512ce9b855959ad301605a
Gitweb:     http://git.kernel.org/tip/459ec28ab404d7afcd512ce9b855959ad301605a
Author:     Ingo Molnar <[email protected]>
AuthorDate: Sun, 13 Sep 2009 17:33:44 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 13 Sep 2009 17:33:44 +0200

perf_counter: Allow mmap if paranoid checks are turned off

Before:

  $ perf sched record -f sleep 1
  Error: failed to mmap with 1 (Operation not permitted)

After:

  $ perf sched record -f sleep 1
  [ perf record: Captured and wrote 0.095 MB perf.data (~4161 samples) ]

Note, this is only allowed if perfcounter_paranoid is set to the most permissive (non-default) value of -1.

Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <new-submission>

---
 kernel/perf_counter.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
kernel/perf_counter.c +2 -1
index e0d91fd..667ab25 100644
@@ -2315,7 +2315,8 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	lock_limit >>= PAGE_SHIFT;
 	locked = vma->vm_mm->locked_vm + extra;
 
-	if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
+	if ((locked > lock_limit) && perf_paranoid_tracepoint_raw() &&
+		!capable(CAP_IPC_LOCK)) {
 		ret = -EPERM;
 		goto unlock;
 	}