stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: <gregkh@linuxfoundation.org>
Cc: alexander.levin@verizon.com, ananth@linux.vnet.ibm.com,
	mingo@kernel.org, naveen.n.rao@linux.vnet.ibm.com,
	paulmck@linux.vnet.ibm.com, peterz@infradead.org,
	rostedt@goodmis.org, tglx@linutronix.de,
	torvalds@linux-foundation.org, <stable@vger.kernel.org>,
	<stable-commits@vger.kernel.org>
Subject: Re: Patch "kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y" has been added to the 4.14-stable tree
Date: Thu, 7 Dec 2017 08:34:56 +0900	[thread overview]
Message-ID: <20171207083456.eac5cac1f01e795dc11c7c8e@kernel.org> (raw)
In-Reply-To: <151258115511913@kroah.com>

On Wed, 06 Dec 2017 18:25:55 +0100
<gregkh@linuxfoundation.org> wrote:

> 
> This is a note to let you know that I've just added the patch titled
> 
>     kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y
> 
> to the 4.14-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      kprobes-use-synchronize_rcu_tasks-for-optprobe-with-config_preempt-y.patch
> and it can be found in the queue-4.14 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

this depends on
commit 7e42776d5ed1f ("rcu: Drive TASKS_RCU directly off of PREEMPT")

So, pull above commit too, for 4.14 and 4.9. But I'm not sure TASKS_RCU is
introduced on 3.18.

Thank you,

> 
> 
> From foo@baz Wed Dec  6 18:04:41 CET 2017
> From: Masami Hiramatsu <mhiramat@kernel.org>
> Date: Fri, 20 Oct 2017 08:43:39 +0900
> Subject: kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y
> 
> From: Masami Hiramatsu <mhiramat@kernel.org>
> 
> 
> [ Upstream commit a30b85df7d599f626973e9cd3056fe755bd778e0 ]
> 
> We want to wait for all potentially preempted kprobes trampoline
> execution to have completed. This guarantees that any freed
> trampoline memory is not in use by any task in the system anymore.
> synchronize_rcu_tasks() gives such a guarantee, so use it.
> 
> Also, this guarantees to wait for all potentially preempted tasks
> on the instructions which will be replaced with a jump.
> 
> Since this becomes a problem only when CONFIG_PREEMPT=y, enable
> CONFIG_TASKS_RCU=y for synchronize_rcu_tasks() in that case.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com>
> Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Link: http://lkml.kernel.org/r/150845661962.5443.17724352636247312231.stgit@devbox
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  arch/Kconfig     |    2 +-
>  kernel/kprobes.c |   14 ++++++++------
>  2 files changed, 9 insertions(+), 7 deletions(-)
> 
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -91,7 +91,7 @@ config STATIC_KEYS_SELFTEST
>  config OPTPROBES
>  	def_bool y
>  	depends on KPROBES && HAVE_OPTPROBES
> -	depends on !PREEMPT
> +	select TASKS_RCU if PREEMPT
>  
>  config KPROBES_ON_FTRACE
>  	def_bool y
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -573,13 +573,15 @@ static void kprobe_optimizer(struct work
>  	do_unoptimize_kprobes();
>  
>  	/*
> -	 * Step 2: Wait for quiesence period to ensure all running interrupts
> -	 * are done. Because optprobe may modify multiple instructions
> -	 * there is a chance that Nth instruction is interrupted. In that
> -	 * case, running interrupt can return to 2nd-Nth byte of jump
> -	 * instruction. This wait is for avoiding it.
> +	 * Step 2: Wait for quiesence period to ensure all potentially
> +	 * preempted tasks to have normally scheduled. Because optprobe
> +	 * may modify multiple instructions, there is a chance that Nth
> +	 * instruction is preempted. In that case, such tasks can return
> +	 * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
> +	 * Note that on non-preemptive kernel, this is transparently converted
> +	 * to synchronoze_sched() to wait for all interrupts to have completed.
>  	 */
> -	synchronize_sched();
> +	synchronize_rcu_tasks();
>  
>  	/* Step 3: Optimize kprobes after quiesence period */
>  	do_optimize_kprobes();
> 
> 
> Patches currently in stable-queue which might be from mhiramat@kernel.org are
> 
> queue-4.14/kprobes-use-synchronize_rcu_tasks-for-optprobe-with-config_preempt-y.patch
> queue-4.14/kprobes-x86-disable-preemption-in-ftrace-based-jprobes.patch


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  parent reply	other threads:[~2017-12-06 23:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06 17:25 Patch "kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT=y" has been added to the 4.14-stable tree gregkh
2017-12-06 20:16 ` Naveen N. Rao
2017-12-07  7:55   ` Greg KH
2017-12-06 23:34 ` Masami Hiramatsu [this message]
2017-12-07  7:52   ` Greg KH

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=20171207083456.eac5cac1f01e795dc11c7c8e@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=alexander.levin@verizon.com \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).