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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YhZJhSD3QyNSG/bP@hirez.programming.kicks-ass.net>
Date:   Wed, 23 Feb 2022 15:49:41 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     Josh Poimboeuf <jpoimboe@...hat.com>, x86@...nel.org,
        joao@...rdrivepizza.com, hjl.tools@...il.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, Miroslav Benes <mbenes@...e.cz>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Alexei Starovoitov <alexei.starovoitov@...il.com>
Subject: Re: [PATCH 04/29] x86/livepatch: Validate __fentry__ location

On Wed, Feb 23, 2022 at 09:23:27AM -0500, Steven Rostedt wrote:
> On Wed, 23 Feb 2022 07:41:39 -0500
> Steven Rostedt <rostedt@...dmis.org> wrote:
> 
> > > --- a/kernel/trace/ftrace.c
> > > +++ b/kernel/trace/ftrace.c
> > > @@ -1578,7 +1578,23 @@ unsigned long ftrace_location_range(unsi
> > >   */
> > >  unsigned long ftrace_location(unsigned long ip)
> > >  {
> > > -	return ftrace_location_range(ip, ip);
> > > +	struct dyn_ftrace *rec;
> > > +	unsigned long offset;
> > > +	unsigned long size;
> > > +
> > > +	rec = lookup_rec(ip, ip);
> > > +	if (!rec) {
> > > +		if (!kallsyms_lookup_size_offset(ip, &size, &offset))
> > > +			goto out;
> > > +

		if (!offset)

> > > +		rec = lookup_rec(ip - offset, (ip - offset) + size);
> > > +	}
> > > +  
> > 
> > Please create a new function for this. Perhaps find_ftrace_location().
> > 
> > ftrace_location() is used to see if the address given is a ftrace
> > nop or not. This change will make it always return true.
> 
> Now we could do:
> 
> 	return ip <= (rec->ip + MCOUNT_INSN_SIZE) ? rec->ip : 0;

I don't see the point of that MCOUNT_INSN_SIZE there, I've done the
above. If +0 then find the entry, wherever it may be.

> Since we would want rec->ip if the pointer is before the ftrace
> instruction. But we would need to audit all use cases and make sure this is
> not called from any hot paths (in a callback).
> 
> This will affect kprobes and BPF as they both use ftrace_location() as well.

Yes, I already fixed kprobes, still trying to (re)discover how to run
the bpf-selftests, that stuff is too painful :-(

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ