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
| ||
|
Message-ID: <Yh/GXaqzDNfp93Jd@hirez.programming.kicks-ass.net> Date: Wed, 2 Mar 2022 20:32:45 +0100 From: Peter Zijlstra <peterz@...radead.org> To: "Naveen N. Rao" <naveen.n.rao@...ux.vnet.ibm.com> Cc: alexei.starovoitov@...il.com, alyssa.milburn@...el.com, andrew.cooper3@...rix.com, hjl.tools@...il.com, joao@...rdrivepizza.com, jpoimboe@...hat.com, keescook@...omium.org, linux-kernel@...r.kernel.org, mark.rutland@....com, mbenes@...e.cz, Masami Hiramatsu <mhiramat@...nel.org>, ndesaulniers@...gle.com, rostedt@...dmis.org, samitolvanen@...gle.com, x86@...nel.org Subject: Re: [PATCH v2 15/39] x86/ibt,kprobes: Fix more +0 assumptions On Wed, Mar 02, 2022 at 09:47:03PM +0530, Naveen N. Rao wrote: > With respect to kprobe_lookup_name(), one of the primary motivations there > was the issue with function descriptors for the previous elf v1 ABI (it > likely also affects ia64/parisc). I'm thinking it'll be simpler if we have a > way to obtain function entry point. Something like this: > > diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h > index 4176c7eca7b5aa..8c57cc5b77f9ae 100644 > --- a/include/linux/kallsyms.h > +++ b/include/linux/kallsyms.h > @@ -73,6 +73,12 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, > /* Lookup the address for a symbol. Returns 0 if not found. */ > unsigned long kallsyms_lookup_name(const char *name); > > +/* Return function entry point by additionally dereferencing function descriptor */ > +static inline unsigned long kallsyms_lookup_function(const char *name) > +{ > + return (unsigned long)dereference_symbol_descriptor((void *)kallsyms_lookup_name(name)); > +} > + > extern int kallsyms_lookup_size_offset(unsigned long addr, > unsigned long *symbolsize, > unsigned long *offset); > @@ -103,6 +109,11 @@ static inline unsigned long kallsyms_lookup_name(const char *name) > return 0; > } > > +static inline unsigned long kallsyms_lookup_function(const char *name) > +{ > + return 0; > +} > + > static inline int kallsyms_lookup_size_offset(unsigned long addr, > unsigned long *symbolsize, > unsigned long *offset) > > > With that, we can fold some of the code from kprobe_lookup_name() into > arch_adjust_kprobe_addr() and remove kprobe_lookup_name(). This should also > address Masami's concerns with powerpc promoting all probes at function > entry into a probe at the ftrace location. Yes, this looks entirely reasonable to me. > --- > kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, > bool *on_func_entry) > { > *on_func_entry = arch_kprobe_on_func_entry(offset); > +#ifdef PPC64_ELF_ABI_v2 > + /* Promote probes on the GEP to the LEP */ > + if (!offset) > + addr = ppc_function_entry((void *)addr); > +#endif > return (kprobe_opcode_t *)(addr + offset); > } I wonder if you also want to tighten up on_func_entry? Wouldn't the above suggest something like: kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset, bool *on_func_entry) { #ifdef PPC64_ELF_ABI_V2 unsigned long entry = ppc_function_entry((void *)addr) - addr; *on_func_entry = !offset || offset == entry; if (*on_func_entry) offset = entry; #else *on_func_entry = !offset; #endif return (void *)(addr + offset); } Then you can also go and delete the arch_kprobe_on_func_entry rudment. For the rest, Yay at cleanups!, lots of magic code gone.
Powered by blists - more mailing lists