All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	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: Mon, 25 Sep 2017 18:16:19 +0200	[thread overview]
Message-ID: <20170925161619.GA15325@redhat.com> (raw)
In-Reply-To: <6718c4ebec1d71524bb81c907180bad90fc8d3c3.1506061547.git.naveen.n.rao@linux.vnet.ibm.com>

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.

Oleg.

  reply	other threads:[~2017-09-25 16:16 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 [this message]
2017-09-28  7:06     ` Ingo Molnar
2017-09-29 13:27     ` Srikar Dronamraju
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=20170925161619.GA15325@redhat.com \
    --to=oleg@redhat.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=srikar@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.