From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127Ab1IZLTg (ORCPT ); Mon, 26 Sep 2011 07:19:36 -0400 Received: from casper.infradead.org ([85.118.1.10]:37238 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751909Ab1IZLTf convert rfc822-to-8bit (ORCPT ); Mon, 26 Sep 2011 07:19:35 -0400 Subject: Re: [PATCH v5 3.1.0-rc4-tip 1/26] uprobes: Auxillary routines to insert, find, delete uprobes From: Peter Zijlstra To: Stefan Hajnoczi Cc: Srikar Dronamraju , Ingo Molnar , Steven Rostedt , Linux-mm , Arnaldo Carvalho de Melo , Linus Torvalds , Andi Kleen , Hugh Dickins , Christoph Hellwig , Jonathan Corbet , Thomas Gleixner , Masami Hiramatsu , Oleg Nesterov , LKML , Jim Keniston , Roland McGrath , Ananth N Mavinakayanahalli , Andrew Morton Date: Mon, 26 Sep 2011 13:18:38 +0200 In-Reply-To: <20110920154259.GA25610@stefanha-thinkpad.localdomain> References: <20110920115938.25326.93059.sendpatchset@srdronam.in.ibm.com> <20110920115949.25326.2469.sendpatchset@srdronam.in.ibm.com> <20110920154259.GA25610@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Mailer: Evolution 3.0.3- Message-ID: <1317035918.9084.83.camel@twins> Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2011-09-20 at 16:42 +0100, Stefan Hajnoczi wrote: > On Tue, Sep 20, 2011 at 05:29:49PM +0530, Srikar Dronamraju wrote: > > +static void delete_uprobe(struct uprobe *uprobe) > > +{ > > + unsigned long flags; > > + > > + spin_lock_irqsave(&uprobes_treelock, flags); > > + rb_erase(&uprobe->rb_node, &uprobes_tree); > > + spin_unlock_irqrestore(&uprobes_treelock, flags); > > + put_uprobe(uprobe); > > + iput(uprobe->inode); > > Use-after-free when put_uprobe() kfrees() the uprobe? I suspect the caller still has one, and this was the reference for being part of the tree. But yes, that could do with a comment. The comment near atomic_set() in __insert_uprobe() isn't too clear either. /* get access + drop ref */, would naively seem +1 -1 = 0, instead of +1 +1 = 2.