[PATCH] D126137: [X86] Add support for `-mharden-sls=all`

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 11:10:25 PDT 2022


nickdesaulniers added a comment.

In D126137#3530777 <https://reviews.llvm.org/D126137#3530777>, @kristof.beyls wrote:

> Therefore, I wonder if it wouldn't be better to name this -mharden-sls=retbr for more consistency across architectures?

I think it's best to maintain compatibility with GCC; to do so otherwise might be surprising for users.

> Or is the indirect function call case not relevant for x86 (sorry - I'm not up to speed on the details on the x86 side)?

Looks like GCC does not instrument indirect calls from what I can tell:

  $ cat x.c
  void bar(void (*x)(void)) {
    x();
    x();
  }
  $ gcc -mharden-sls=all x.c -c -O2
  $ llvm-objdump -dr x.o           
  ...
  0000000000000000 <bar>:
         0: 53                           	pushq	%rbx
         1: 48 89 fb                     	movq	%rdi, %rbx
         4: ff d7                        	callq	*%rdi
         6: 48 89 d8                     	movq	%rbx, %rax
         9: 5b                           	popq	%rbx
         a: ff e0                        	jmpq	*%rax
         c: cc                           	int3

so the indirect `call` instruction is not hardened. The indirect jmp (tail call) is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126137/new/

https://reviews.llvm.org/D126137



More information about the llvm-commits mailing list