Messages in this thread | | | Date | Tue, 18 Oct 2022 16:47:44 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH] x86/ibt: Implement FineIBT |
| |
On Tue, Oct 18, 2022 at 03:35:50PM +0200, Peter Zijlstra wrote: > +asm( ".pushsection .rodata \n" > + "fineibt_caller_start: \n" > + " movl $0x12345678, %r10d \n" > + " sub $16, %r11 \n" > + ASM_NOP4 > + "fineibt_caller_end: \n" > + ".popsection \n" > +);
Note: this hard relies on the indirection using %r11 and %r11 being clobbered by the call-abi. That is, there is no expectation on the value of %r11 after this.
If GCC were to grow kCFI support this needs additional changes; one option would be to use the 4 byte nop to rewrite it into something like:
movl $0x12345678, %r10d movl %[reg], %r11 sub $16, %r11
> +static int cfi_rewrite_callers(s32 *start, s32 *end) > +{ > + s32 *s; > + > + for (s = start; s < end; s++) { > + void *addr = (void *)s + *s; > + u32 hash; > + > + addr -= fineibt_caller_size; > + hash = decode_caller_hash(addr); > + if (hash) { > + text_poke_early(addr, fineibt_caller_start, fineibt_caller_size); > + WARN_ON(*(u32 *)(addr + fineibt_caller_hash) != 0x12345678); > + text_poke_early(addr + fineibt_caller_hash, &hash, 4); > + } > + /* rely on apply_retpolines() */ > + } > + > + return 0; > +}
| |