Messages in this thread | | | Date | Sat, 6 Oct 2012 15:22:58 +0530 | From | Srikar Dronamraju <> | Subject | Re: [PATCH 6/7] uprobes: Fix uprobe_copy_insn() race with itself |
| |
* Oleg Nesterov <oleg@redhat.com> [2012-09-30 21:42:24]:
> install_breakpoint() is called under mm->mmap_sem, this protects > set_swbp() but not uprobe_copy_insn(). Two or more different tasks > can call install_breakpoint()->uprobe_copy_insn() at the same time, > this leads to numerous problems if UPROBE_COPY_INSN is not set. > > Just for example, the second copy_insn() can corrupt the already > analyzed/fixuped uprobe->arch.insn and race with handle_swbp(). > > This patch simply adds uprobe->copy_mutex to serialize this code. > We could probably reuse ->consumer_rwsem, but this would mean that > consumer->handler() can not use mm->mmap_sem, not good. > > Note: this is another temporary ugly hack until we move this logic > into uprobe_register(). > > Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Given that we copy just for the first install, and register not being a performance path, Can we use a single mutex instead of a per-uprobe mutex.
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
| |