public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Anton Blanchard <anton@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] kernel/uprobes: Fix check for active uprobe
Date: Fri, 29 Sep 2017 06:27:23 -0700	[thread overview]
Message-ID: <20170929132723.GA2318@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170925161619.GA15325@redhat.com>

> >
> > --- 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.
> 

Right, Given that we are doing this in the mmap_sem, we should also be
removing the rmb/wmb pairs too.

Right Oleg?


> And btw, perhaps you should do this check right after find_uprobe() in the
> if (valid_vma) block.
> 
> Oleg.
> 

  parent reply	other threads:[~2017-09-29 13:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22  9:13 [PATCH v3 0/3] A few uprobe fixes Naveen N. Rao
2017-09-22  9:13 ` [PATCH v3 1/3] kernel/uprobes: Do away with uprobe_warn() Naveen N. Rao
2017-09-22  9:13 ` [PATCH v3 2/3] kernel/uprobes: Warn if unable to install breakpoint Naveen N. Rao
2017-09-22  9:13 ` [PATCH v3 3/3] kernel/uprobes: Fix check for active uprobe Naveen N. Rao
2017-09-25 16:16   ` Oleg Nesterov
2017-09-28  7:06     ` Ingo Molnar
2017-09-29 13:27     ` Srikar Dronamraju [this message]
2017-09-29 16:54       ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170929132723.GA2318@linux.vnet.ibm.com \
    --to=srikar@linux.vnet.ibm.com \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=oleg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox