diff options
| author | Peter Zijlstra <[email protected]> | 2009-06-19 15:39:33 +0000 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2009-06-19 15:57:36 +0000 |
| commit | b49a9e7e72103ea91946453c19703a4dfa1994fe (patch) | |
| tree | 7e9e74881384c581afca56cc397901f71e904c8b /tools/perf/builtin-annotate.c | |
| parent | perf_counter, x86: Improve interactions with fast-gup (diff) | |
| download | kernel-b49a9e7e72103ea91946453c19703a4dfa1994fe.tar.gz kernel-b49a9e7e72103ea91946453c19703a4dfa1994fe.zip | |
perf_counter: Close race in perf_lock_task_context()
perf_lock_task_context() is buggy because it can return a dead
context.
the RCU read lock in perf_lock_task_context() only guarantees
the memory won't get freed, it doesn't guarantee the object is
valid (in our case refcount > 0).
Therefore we can return a locked object that can get freed the
moment we release the rcu read lock.
perf_pin_task_context() then increases the refcount and does an
unlock on freed memory.
That increased refcount will cause a double free, in case it
started out with 0.
Ammend this by including the get_ctx() functionality in
perf_lock_task_context() (all users already did this later
anyway), and return a NULL context when the found one is
already dead.
Signed-off-by: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
0 files changed, 0 insertions, 0 deletions
