[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210128090935.719ac21fbfa2b6cfc91dea9c@kernel.org>
Date: Thu, 28 Jan 2021 09:09:35 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Jianlin Lv <Jianlin.Lv@....com>, Oleg Nesterov <oleg@...hat.com>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing/kprobe: Fix to support kretprobe events on
unloaded modules
On Wed, 27 Jan 2021 17:29:50 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Thu, 28 Jan 2021 00:37:51 +0900
> Masami Hiramatsu <mhiramat@...nel.org> wrote:
>
> > Fix kprobe_on_func_entry() returns error code instead of false so that
> > register_kretprobe() can return an appropriate error code.
> >
> > append_trace_kprobe() expects the kprobe registration returns -ENOENT
> > when the target symbol is not found, and it checks whether the target
> > module is unloaded or not. If the target module doesn't exist, it
> > defers to probe the target symbol until the module is loaded.
> >
> > However, since register_kretprobe() returns -EINVAL instead of -ENOENT
> > in that case, it always fail on putting the kretprobe event on unloaded
> > modules. e.g.
> >
> > Kprobe event:
> > /sys/kernel/debug/tracing # echo p xfs:xfs_end_io >> kprobe_events
> > [ 16.515574] trace_kprobe: This probe might be able to register after target module is loaded. Continue.
> >
> > Kretprobe event: (p -> r)
> > /sys/kernel/debug/tracing # echo r xfs:xfs_end_io >> kprobe_events
> > sh: write error: Invalid argument
> > /sys/kernel/debug/tracing # cat error_log
> > [ 41.122514] trace_kprobe: error: Failed to register probe event
> > Command: r xfs:xfs_end_io
> > ^
> >
> > To fix this bug, change kprobe_on_func_entry() to detect symbol lookup
> > failure and return -ENOENT in that case. Otherwise it returns -EINVAL
> > or 0 (succeeded, given address is on the entry).
> >
> > Reported-by: Jianlin Lv <Jianlin.Lv@....com>
> > Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
>
> Is this something that should go to stable? And if so, can you supply a
> Fixes tag?
Yes, I thought that had not supported previously, but that's wrong.
I found below commit introduced -ENOENT check in trace_kprobe side.
Fixes: 59158ec4aef7 ("tracing/kprobes: Check the probe on unloaded module correctly")
Thank you,
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists