Skip to content

Commit

Permalink
perfcounters: fix use after free in perf_release()
Browse files Browse the repository at this point in the history
running...

  while true; do
    foo -d 1 -f 1 -c 100000 & sleep 1
    kerneltop -d 1 -f 1 -e 1 -c 25000 -p `pidof foo`
  done

  while true; do
    killall foo; killall kerneltop; sleep 2
  done

...in two shells with SLUB_DEBUG enabled produces flood of:
BUG task_struct: Poison overwritten.

Fix the use-after-free bug in perf_release().

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Mike Galbraith authored and Ingo Molnar committed Feb 11, 2009
1 parent ffc0467 commit 5af7591
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,12 +1145,12 @@ static int perf_release(struct inode *inode, struct file *file)
mutex_lock(&counter->mutex);

perf_counter_remove_from_context(counter);
put_context(ctx);

mutex_unlock(&counter->mutex);
mutex_unlock(&ctx->mutex);

kfree(counter);
put_context(ctx);

return 0;
}
Expand Down

0 comments on commit 5af7591

Please sign in to comment.