Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1642662

Re: WARNING at arch/x86/kernel/alternative.c:707 text_poke+0x25d/0x270

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject Re: WARNING at arch/x86/kernel/alternative.c:707 text_poke+0x25d/0x270
Date 2017-05-16 18:30 +0200
Message-ID <tHNwd-7SQ-9@gated-at.bofh.it> (permalink)
References <tHL1n-6fA-11@gated-at.bofh.it> <tHMqu-7gj-15@gated-at.bofh.it> <tHMJP-7nR-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 16 May 2017 11:30:19 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 17 May 2017 00:15:39 +0900
> Masami Hiramatsu <mhiramat@kernel.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...
> 
> Hmm, what happens if you add a kprobe to a module, remove it, and then
> remove the module.

In that case the kprobe will be removed before unloading the module.
If the kprobe is optimized, the optimized probe itself is queued
to unoptimize.

> If the module is still loaded when it is removed,
> wouldn't that cause the optimized probe to be delayed?

Yes, it is queued, but before unloading module, it should be
dequeued forcibly by kill_optimized_kprobe() from module-notifier.

> Wouldn't that
> open a race where the optimizer work queue can be called when no module
> exists?

Since both kprobe_mutex and module_mutex are held in optimizer,
I couldn't think there is such race. I guess when the kernel's
init-text (not module's one) is freed, it doesn't kick the
module notifier and kprobes missed that.

Thank you,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

WARNING at arch/x86/kernel/alternative.c:707 text_poke+0x25d/0x270 Steven Rostedt <rostedt@goodmis.org> - 2017-05-16 15:50 +0200
  Re: WARNING at arch/x86/kernel/alternative.c:707  text_poke+0x25d/0x270 Masami Hiramatsu <mhiramat@kernel.org> - 2017-05-16 17:20 +0200
    Re: WARNING at arch/x86/kernel/alternative.c:707  text_poke+0x25d/0x270 Steven Rostedt <rostedt@goodmis.org> - 2017-05-16 17:40 +0200
      Re: WARNING at arch/x86/kernel/alternative.c:707  text_poke+0x25d/0x270 Masami Hiramatsu <mhiramat@kernel.org> - 2017-05-16 18:30 +0200
    Re: WARNING at arch/x86/kernel/alternative.c:707  text_poke+0x25d/0x270 Thomas Gleixner <tglx@linutronix.de> - 2017-05-16 23:50 +0200
      Re: WARNING at arch/x86/kernel/alternative.c:707  text_poke+0x25d/0x270 Masami Hiramatsu <mhiramat@kernel.org> - 2017-05-17 03:40 +0200

csiph-web