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]
Message-ID: <YhY/NpGRq8Dv4etZ@hirez.programming.kicks-ass.net>
Date:   Wed, 23 Feb 2022 15:05:42 +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>
Subject: Re: [PATCH 04/29] x86/livepatch: Validate __fentry__ location

On Wed, Feb 23, 2022 at 07:41:39AM -0500, Steven Rostedt wrote:
> On Wed, 23 Feb 2022 11:57:26 +0100
> Peter Zijlstra <peterz@...radead.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;
> > +
> > +		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.
> 

# git grep ftrace_location
arch/powerpc/include/asm/livepatch.h:#define klp_get_ftrace_location klp_get_ftrace_location
arch/powerpc/include/asm/livepatch.h:static inline unsigned long klp_get_ftrace_location(unsigned long faddr)
arch/powerpc/include/asm/livepatch.h:   return ftrace_location_range(faddr, faddr + 16);
arch/powerpc/kernel/kprobes.c:          faddr = ftrace_location_range((unsigned long)addr,
arch/x86/kernel/kprobes/core.c: faddr = ftrace_location(addr);
arch/x86/kernel/kprobes/core.c:  * arch_check_ftrace_location(). Something went terribly wrong
include/linux/ftrace.h:unsigned long ftrace_location(unsigned long ip);
include/linux/ftrace.h:unsigned long ftrace_location_range(unsigned long start, unsigned long end);
include/linux/ftrace.h:static inline unsigned long ftrace_location(unsigned long ip)
kernel/bpf/trampoline.c:static int is_ftrace_location(void *ip)
kernel/bpf/trampoline.c:        addr = ftrace_location((long)ip);
kernel/bpf/trampoline.c:        ret = is_ftrace_location(ip);
kernel/kprobes.c:               unsigned long faddr = ftrace_location((unsigned long)addr);
kernel/kprobes.c:static int check_ftrace_location(struct kprobe *p)
kernel/kprobes.c:       ftrace_addr = ftrace_location((unsigned long)p->addr);
kernel/kprobes.c:       ret = check_ftrace_location(p);
kernel/livepatch/patch.c:#ifndef klp_get_ftrace_location
kernel/livepatch/patch.c:static unsigned long klp_get_ftrace_location(unsigned long faddr)
kernel/livepatch/patch.c:       return ftrace_location(faddr);
kernel/livepatch/patch.c:                       klp_get_ftrace_location((unsigned long)func->old_func);
kernel/livepatch/patch.c:                       klp_get_ftrace_location((unsigned long)func->old_func);
kernel/trace/ftrace.c: * ftrace_location_range - return the first address of a traced location
kernel/trace/ftrace.c:unsigned long ftrace_location_range(unsigned long start, unsigned long end)
kernel/trace/ftrace.c: * ftrace_location - return true if the ip giving is a traced location
kernel/trace/ftrace.c:unsigned long ftrace_location(unsigned long ip)
kernel/trace/ftrace.c:  ret = ftrace_location_range((unsigned long)start,
kernel/trace/ftrace.c:  if (!ftrace_location(ip))
kernel/trace/ftrace.c:  ip = ftrace_location(ip);
kernel/trace/ftrace.c:  ip = ftrace_location(ip);
kernel/trace/trace_kprobe.c:     * Since ftrace_location_range() does inclusive range check, we need
kernel/trace/trace_kprobe.c:    return !ftrace_location_range(addr, addr + size - 1);

and yet almost every caller takes the address it returns...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ