Messages in this thread | | | Date | Sat, 17 Apr 2021 00:14:14 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH 05/15] x86: Implement function_nocfi |
| |
On Fri, Apr 16, 2021 at 03:06:17PM -0700, Andy Lutomirski wrote: > On Fri, Apr 16, 2021 at 3:03 PM Borislav Petkov <bp@alien8.de> wrote: > > > > On Fri, Apr 16, 2021 at 02:49:23PM -0700, Sami Tolvanen wrote: > > > __nocfi only disables CFI checking in a function, the compiler still > > > changes function addresses to point to the CFI jump table, which is > > > why we need function_nocfi(). > > > > So call it __func_addr() or get_function_addr() or so, so that at least > > it is clear what this does. > > > > This seems backwards to me. If I do: > > extern void foo(some signature); > > then I would, perhaps naively, expect foo to be the actual symbol that
I'm just reading the patch:
... The function_nocfi macro always returns the address of the + * actual function instead. + */ +#define function_nocfi(x) ({ \ + void *addr; \ + asm("leaq " __stringify(x) "(%%rip), %0\n\t" : "=r" (addr)); \ + addr;
so it does a rip-relative load into a reg which ends up with the function address.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |