lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 2 Mar 2022 09:11:50 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     x86@...nel.org, joao@...rdrivepizza.com, hjl.tools@...il.com,
        jpoimboe@...hat.com, andrew.cooper3@...rix.com,
        linux-kernel@...r.kernel.org, ndesaulniers@...gle.com,
        keescook@...omium.org, samitolvanen@...gle.com,
        mark.rutland@....com, alyssa.milburn@...el.com, mbenes@...e.cz,
        rostedt@...dmis.org, alexei.starovoitov@...il.com,
        naveen.n.rao@...ux.vnet.ibm.com
Subject: Re: [PATCH v2 15/39] x86/ibt,kprobes: Fix more +0 assumptions

On Tue, 1 Mar 2022 09:28:49 +0100
Peter Zijlstra <peterz@...radead.org> wrote:

> On Tue, Mar 01, 2022 at 11:49:05AM +0900, Masami Hiramatsu wrote:
> > > +static kprobe_opcode_t *
> > > +_kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
> > > +	     unsigned long offset, bool *on_func_entry)
> > >  {
> > >  	if ((symbol_name && addr) || (!symbol_name && !addr))
> > >  		goto invalid;
> > >  
> > >  	if (symbol_name) {
> > > +		/*
> > > +		 * Input: @sym + @offset
> > > +		 * Output: @addr + @offset
> > > +		 *
> > > +		 * NOTE: kprobe_lookup_name() does *NOT* fold the offset
> > > +		 *       argument into it's output!
> > > +		 */
> > >  		addr = kprobe_lookup_name(symbol_name, offset);
> > 
> > Hmm, there are 2 issues.
> > 
> > - the 'addr' includes the 'offset' here.
> 
> AFAICT it doesn't (I ever wrote that in the comment on top). There's two
> implementations of kprobe_lookup_name(), the weak version doesn't even
> use the offset argument, and the PowerPC implementation only checks for
> !offset and doesn't fold it.

Oops, OK.

> 
> > - the 'offset' is NOT limited under the symbol size.
> >   (e.g. symbol_name = "_text" and @offset points the offset of target symbol from _text)
> > 
> > This means we need to call kallsyms_lookup_size_offset() in this case too.
> 
> I'm feeling we should error out in that case. Using sym+offset beyond
> the limits of sym is just daft.

No, this is required for pointing some local scope functions, which has
same name. (And perf-probe does that)

> 
> But if you really want/need to retain that, then yes, we need that
> else branch unconditionally :/

Thank you,

-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ