alistair23-linux/kernel/events
Oleg Nesterov 32cdba1e05 uprobes: Use percpu_rw_semaphore to fix register/unregister vs dup_mmap() race
This was always racy, but 268720903f
"uprobes: Rework register_for_each_vma() to make it O(n)" should be
blamed anyway, it made everything worse and I didn't notice.

register/unregister call build_map_info() and then do install/remove
breakpoint for every mm which mmaps inode/offset. This can obviously
race with fork()->dup_mmap() in between and we can miss the child.

uprobe_register() could be easily fixed but unregister is much worse,
the new mm inherits "int3" from parent and there is no way to detect
this if uprobe goes away.

So this patch simply adds percpu_down_read/up_read around dup_mmap(),
and percpu_down_write/up_write into register_for_each_vma().

This adds 2 new hooks into dup_mmap() but we can kill uprobe_dup_mmap()
and fold it into uprobe_end_dup_mmap().

Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
2012-11-16 14:52:51 +01:00
..
callchain.c perf: Add attribute to filter out callchains 2012-08-10 12:40:57 -03:00
core.c Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-10-13 10:20:11 +09:00
hw_breakpoint.c perf/hwpb: Invoke __perf_event_disable() if interrupts are already disabled 2012-09-04 17:29:53 +02:00
internal.h perf: Add ability to attach user stack dump to sample 2012-08-10 12:17:58 -03:00
Makefile uprobes: Move to kernel/events/ 2012-02-22 11:08:00 +01:00
ring_buffer.c perf: Add perf_output_skip function to skip bytes in sample 2012-08-10 12:16:22 -03:00
uprobes.c uprobes: Use percpu_rw_semaphore to fix register/unregister vs dup_mmap() race 2012-11-16 14:52:51 +01:00