[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110617045000.GM4952@linux.vnet.ibm.com>
Date: Fri, 17 Jun 2011 10:20:00 +0530
From: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
Linux-mm <linux-mm@...ck.org>,
Arnaldo Carvalho de Melo <acme@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andi Kleen <andi@...stfloor.org>,
Hugh Dickins <hughd@...gle.com>,
Christoph Hellwig <hch@...radead.org>,
Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Oleg Nesterov <oleg@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
Jim Keniston <jkenisto@...ux.vnet.ibm.com>,
Roland McGrath <roland@...k.frob.com>,
Ananth N Mavinakayanahalli <ananth@...ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v4 3.0-rc2-tip 7/22] 7: uprobes: mmap and fork hooks.
>
> void __unregister_uprobe(...)
> {
> uprobe = find_uprobe(); // ref++
> if (delete_consumer(...)); // includes tree removal on last consumer
> // implies we own the last ref
> return; // consumers
>
> vma_prio_tree_foreach() {
> // create list
> }
>
> list_for_each_entry_safe() {
> // remove from list
> remove_breakpoint(); // unconditional, if it wasn't there
> // its a nop anyway, can't get any new
> // new probes on account of holding
> // uprobes_mutex and mmap() doesn't see
> // it due to tree removal.
> }
> }
>
This would have a bigger race.
A breakpoint might be hit by which time the node is removed and we
have no way to find out the uprobe. So we deliver an extra TRAP to the
app.
> int mmap_uprobe(...)
> {
> spin_lock(&uprobes_treelock);
> for_each_probe_in_inode() {
> // create list;
> }
> spin_unlock(..);
>
> list_for_each_entry_safe() {
> // remove from list
> ret = install_breakpoint();
> if (ret)
> goto fail;
> if (!uprobe_still_there()) // takes treelock
> remove_breakpoint();
> }
>
> return 0;
>
> fail:
> list_for_each_entry_safe() {
> // destroy list
> }
> return ret;
> }
>
register_uprobe will race with mmap_uprobe's first pass.
So we might end up with a vma that doesnot have a breakpoint inserted
but inserted in all other vma that map to the same inode.
--
Thanks and Regards
Srikar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists