From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbdI1HGN (ORCPT ); Thu, 28 Sep 2017 03:06:13 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37918 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbdI1HGM (ORCPT ); Thu, 28 Sep 2017 03:06:12 -0400 X-Google-Smtp-Source: AOwi7QC6ojZc3cUb83GJ2BMbCbgxubsXcQG1y5gL0zfjKg4AJ/R8Ox0oeZxNnql7LF1Jw+6B+Vgy8Q== Date: Thu, 28 Sep 2017 09:06:08 +0200 From: Ingo Molnar To: Oleg Nesterov Cc: "Naveen N. Rao" , Srikar Dronamraju , Ananth N Mavinakayanahalli , Anton Blanchard , Michael Ellerman , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] kernel/uprobes: Fix check for active uprobe Message-ID: <20170928070608.danalxb2obvhav4z@gmail.com> References: <6718c4ebec1d71524bb81c907180bad90fc8d3c3.1506061547.git.naveen.n.rao@linux.vnet.ibm.com> <20170925161619.GA15325@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170925161619.GA15325@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Oleg Nesterov wrote: > On 09/22, Naveen N. Rao wrote: > > > > --- a/kernel/events/uprobes.c > > +++ b/kernel/events/uprobes.c > > @@ -1751,6 +1751,19 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp) > > uprobe = find_uprobe(inode, offset); > > } > > > > + /* Ensure that the breakpoint was actually installed */ > > + if (uprobe) { > > + /* > > + * TODO: move copy_insn/etc into _register and remove > > + * this hack. After we hit the bp, _unregister + > > + * _register can install the new and not-yet-analyzed > > + * uprobe at the same address, restart. > > + */ > > + smp_rmb(); /* pairs with wmb() in prepare_uprobe() */ > > + if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) > > + uprobe = NULL; > > + } > > ACK ... > > but the comment is no longer valid, it only mentions the race unregister + > register. > > And note that "restart" is not true in that we are not going to simply restart, > we will check is_trap_at_addr() and then either send SIGTRAP or restart. > > This is correct because we do this check under mmap_sem so we can't race with > install_breakpoint(), so is_trap_at_addr() == T can't be falsely true if > UPROBE_COPY_INSN is not set. > > And btw, perhaps you should do this check right after find_uprobe() in the > if (valid_vma) block. Ok guys - I'll wait for the next iteration that incorporates Oleg's suggestions. Thanks, Ingo