Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1581520
| From | "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] kretprobes: reject registration if a symbol offset is specified |
| Date | 2017-02-15 19:00 +0100 |
| Message-ID | <tbc1Z-32F-29@gated-at.bofh.it> (permalink) |
| References | <taGOt-7QG-3@gated-at.bofh.it> <taIGC-HJ-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Masami,
On 2017/02/14 07:32PM, Masami Hiramatsu wrote:
> On Tue, 14 Feb 2017 14:01:18 +0530
> "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
>
> > Users shouldn't be able to specify an offset with kretprobes, as we always
> > want to probe at function entry. Otherwise, we won't be able to capture
> > the proper return address resulting in the kretprobe never firing.
> >
>
> Nack, this should be checked by using kallsyms, since the
> many non-exported kernel functions have same name.
> Actually perf-probe is trying to put any probes(including return
> probe) by using relative address from text-start symbol (_stext
> or _text). In this case, kretprobe also can be set by _text+OFFSET.
Interesting. In my tests, 'perf probe' always chose the function name
for return probes on both x86 and powerpc. So, looking into it further,
I found commit 25dd9171f51c ("perf probe: Fix probing kretprobes") which
changed perf probe behavior due to how kprobe_events behaved. And
kprobe_events has always dis-allowed use of offset with kprobe_events.
But, I agree -- we should allow use of offset with kretprobes.
Otherwise, we won't be able to probe functions that have the same name.
>
> So please rewrite this by using kallsyms_lookup_size_offset()
> which tells you the address is actually on the beginning of
> function or not.
Sure. This makes use of offsets and/or absolute addresses with
kretprobes safe. Patches on the way...
Thanks!
- Naveen
>
> Thank you,
>
> > With samples/kprobes/kretprobe_example.c including an offset:
> > my_kretprobe.kp.offset = 40;
> >
> > Before this patch, the probe gets planted but never fires.
> >
> > After this patch:
> > $ sudo insmod samples/kprobes/kretprobe_example.ko
> > [sudo] password for naveen:
> > insmod: ERROR: could not insert module samples/kprobes/kretprobe_example.ko: Operation not permitted
> >
> > And dmesg:
> > [48253.757629] register_kretprobe failed, returned -22
> >
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> > kernel/kprobes.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 60a702a05684..83ad7e440417 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -1847,6 +1847,9 @@ int register_kretprobe(struct kretprobe *rp)
> > int i;
> > void *addr;
> >
> > + if (rp->kp.offset)
> > + return -EINVAL;
> > +
> > if (kretprobe_blacklist_size) {
> > addr = kprobe_addr(&rp->kp);
> > if (IS_ERR(addr))
> > --
> > 2.11.0
> >
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] kretprobes: reject registration if a symbol offset is specified "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-14 09:40 +0100
Re: [PATCH] kretprobes: reject registration if a symbol offset is specified Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> - 2017-02-14 09:50 +0100
Re: [PATCH] kretprobes: reject registration if a symbol offset is specified Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-14 11:40 +0100
Re: [PATCH] kretprobes: reject registration if a symbol offset is specified "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-15 19:00 +0100
[PATCH 3/3] perf: revert "perf probe: Fix probing kretprobes" "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-15 19:20 +0100
Re: [PATCH 3/3] perf: revert "perf probe: Fix probing kretprobes" Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-16 00:50 +0100
[PATCH 1/3] kretprobes: ensure probe location is at function entry "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-15 19:20 +0100
[PATCH 2/3] trace/kprobes: allow return probes with offsets and absolute addresses "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-15 19:20 +0100
Re: [PATCH 2/3] trace/kprobes: allow return probes with offsets and absolute addresses Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-16 00:50 +0100
Re: [PATCH 1/3] kretprobes: ensure probe location is at function entry Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-16 00:50 +0100
Re: [PATCH 1/3] kretprobes: ensure probe location is at function entry "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 09:00 +0100
[PATCH 0/2] powerpc: kretprobe updates "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 09:20 +0100
[PATCH 1/2] powerpc: kretprobes: override default function entry offset "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 09:20 +0100
[PATCH 2/2] perf: powerpc: choose LEP with kretprobes "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-16 09:20 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-17 11:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-17 21:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-19 05:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-20 11:00 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-21 14:10 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-22 14:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-20 10:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-02-20 12:50 +0100
Re: [PATCH 0/2] powerpc: kretprobe updates Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-21 14:10 +0100
Re: [PATCH] kretprobes: reject registration if a symbol offset is specified Masami Hiramatsu <mhiramat@kernel.org> - 2017-02-16 00:30 +0100
csiph-web