From: Masami Hiramatsu <mhiramat@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: WARNING at arch/x86/kernel/alternative.c:707 text_poke+0x25d/0x270
Date: Wed, 17 May 2017 10:38:34 +0900 [thread overview]
Message-ID: <20170517103834.5e8642a26e2e49369c88bf0d@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1705162340300.2095@nanos>
On Tue, 16 May 2017 23:42:58 +0200 (CEST)
Thomas Gleixner <tglx@linutronix.de> wrote:
> On Wed, 17 May 2017, Masami Hiramatsu wrote:
> > On Tue, 16 May 2017 09:48:02 -0400
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> > > It appears that the kprobe_optimizer work thread call happened after
> > > the init pages were freed, causing alternative.c to give the above
> > > warning because the text that is being unoptimized happens to no longer
> > > exist.
> >
> > Ah, I see. I need to check that case. Actually for the module
> > init text area, kill_kprobe() correctly kicks kill_optimized_kprobe()
> > so it should safe. But above case is on the init-text in kernel
> > itself. I guess module_notifier may not be called for that area...
>
> Find below the patch I'm using for now .
Thank you very much! It looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
>
> Thanks,
>
> tglx
>
> 8<--------------------
>
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -349,6 +349,9 @@ extern int proc_kprobes_optimization_han
> int write, void __user *buffer,
> size_t *length, loff_t *ppos);
> #endif
> +extern void wait_for_kprobe_optimizer(void);
> +#else
> +static inline void wait_for_kprobe_optimizer(void) { }
> #endif /* CONFIG_OPTPROBES */
> #ifdef CONFIG_KPROBES_ON_FTRACE
> extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -595,7 +595,7 @@ static void kprobe_optimizer(struct work
> }
>
> /* Wait for completing optimization and unoptimization */
> -static void wait_for_kprobe_optimizer(void)
> +void wait_for_kprobe_optimizer(void)
> {
> mutex_lock(&kprobe_mutex);
>
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -1535,6 +1535,11 @@ static __init int kprobe_trace_self_test
>
> end:
> release_all_trace_kprobes();
> + /*
> + * Wait for the optimizer work to finish. Otherwise it might fiddle
> + * with probes in already freed __init text.
> + */
> + wait_for_kprobe_optimizer();
> if (warn)
> pr_cont("NG: Some tests are failed. Please check them.\n");
> else
--
Masami Hiramatsu <mhiramat@kernel.org>
prev parent reply other threads:[~2017-05-17 1:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 13:48 Steven Rostedt
2017-05-16 15:15 ` Masami Hiramatsu
2017-05-16 15:30 ` Steven Rostedt
2017-05-16 16:27 ` Masami Hiramatsu
2017-05-16 21:42 ` Thomas Gleixner
2017-05-17 1:38 ` Masami Hiramatsu [this message]
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=20170517103834.5e8642a26e2e49369c88bf0d@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome