uprobes: Change register_for_each_vma() to take mm->mmap_sem for writing
authorOleg Nesterov <[email protected]>
Tue, 29 May 2012 19:29:28 +0000 (21:29 +0200)
committerIngo Molnar <[email protected]>
Wed, 6 Jun 2012 15:21:48 +0000 (17:21 +0200)
commit77fc4af1b59d12ab3b1467adf0a5204806853123
tree0df96ddd6503d47d665e09edef76e3cd12b15b70
parentd790d34653ab20c74034902f5f0889bba807949a
uprobes: Change register_for_each_vma() to take mm->mmap_sem for writing

Change register_for_each_vma() to take mm->mmap_sem for writing.
This is a bit unfortunate but hopefully not too bad, this is the
slow path anyway.

This is needed to ensure that find_active_uprobe() can not race
with uprobe_register() which adds the new bp at the same
bp_vaddr, after find_uprobe() fails and before
is_swbp_at_addr_fast() checks the memory.

IOW, this is needed to ensure that if find_active_uprobe()
returns NULL but is_swbp == true, we can safely assume that it
was the "normal" int3 and we should send SIGTRAP.

There is another reason for this change. We are going to replace
uprobes_state->count with MMF_ flags set by register/unregister
and cleared by find_active_uprobe(), and set/clear shouldn't
race with each other.

Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Srikar Dronamraju <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Anton Arapov <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/events/uprobes.c