[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200324144953.eec3e73f249901582bdf564e@kernel.org>
Date: Tue, 24 Mar 2020 14:49:53 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
Paul McKenney <paulmck@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
"Joel Fernandes \(Google\)" <joel@...lfernandes.org>,
"Steven Rostedt \(VMware\)" <rostedt@...dmis.org>,
Alexei Starovoitov <ast@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Brian Gerst <brgerst@...il.com>,
Juergen Gross <jgross@...e.com>,
Alexandre Chartre <alexandre.chartre@...cle.com>,
Peter Zijlstra <peterz@...radead.org>,
Tom Lendacky <thomas.lendacky@....com>,
Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org
Subject: Re: [patch V3 04/23] kprobes: Prevent probes in .noinstr.text
section
On Mon, 23 Mar 2020 17:03:24 +0100
Thomas Gleixner <tglx@...utronix.de> wrote:
> Masami,
>
> Masami Hiramatsu <mhiramat@...nel.org> writes:
> > On Fri, 20 Mar 2020 19:00:00 +0100
> > Thomas Gleixner <tglx@...utronix.de> wrote:
> >
> >> Instrumentation is forbidden in the .noinstr.text section. Make kprobes
> >> respect this.
> >>
> >> This lacks support for .noinstr.text sections in modules, which is required
> >> to handle VMX and SVM.
> >>
> >
> > Would you have any plan to list or mark the noinstr symbols on
> > some debugfs interface? I need a blacklist of those symbols so that
> > user (and perf-probe) can check which function can not be probed.
> >
> > It is just calling kprobe_add_area_blacklist() like below.
> >
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 2625c241ac00..4835b644bd2b 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -2212,6 +2212,10 @@ static int __init populate_kprobe_blacklist(unsigned long *start,
> > ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
> > (unsigned long)__kprobes_text_end);
> >
> > + /* Symbols in noinstr section are blacklisted */
> > + ret = kprobe_add_area_blacklist((unsigned long)__noinstr_text_start,
> > + (unsigned long)__noinstr_text_end);
> > +
> > return ret ? : arch_populate_kprobe_blacklist();
> > }
>
> So that extra function is not required when adding that, right?
That's right :)
>
> >> +/* Functions in .noinstr.text must not be probed */
> >> +static bool within_noinstr_text(unsigned long addr)
> >> +{
> >> + /* FIXME: Handle module .noinstr.text */
And this reminds me that the module .kprobes.text is not handled yet :(.
Thank you,
> >> + return addr >= (unsigned long)__noinstr_text_start &&
> >> + addr < (unsigned long)__noinstr_text_end;
> >> +}
> >> +
> >> bool within_kprobe_blacklist(unsigned long addr)
> >> {
> >> char symname[KSYM_NAME_LEN], *p;
> >>
> >> + if (within_noinstr_text(addr))
> >> + return true;
> >> +
> >> if (__within_kprobe_blacklist(addr))
> >> return true;
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists