Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Implement -fzero-call-used-regs #36853

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37880
Status NEW
Importance P enhancement
Reported by Nick Desaulniers (ndesaulniers@google.com)
Reported on 2018-06-20 09:22:52 -0700
Last modified on 2021-09-17 12:06:27 -0700
Version trunk
Hardware PC Linux
CC isanbard@gmail.com, jyknight@google.com, keescook@chromium.org, klimek@google.com, llozano@chromium.org, llvm-bugs@lists.llvm.org, llvm-dev@ndave.org, manojgupta@google.com, srhines@google.com
Fixed by commit(s)
Attachments
Blocks PR4068
Blocked by
See also

GCC has added ways of specifying that certain registers should be zero'd upon function return. I believe this is to help cut down on gadgets used in ROP chains. Is this something that could be added in Clang?

https://github.com/clearlinux-pkgs/gcc/blob/master/zero-regs-gcc8.patch

Quuxplusone commented 4 years ago

Here's a better link: https://gcc.gnu.org/legacy-ml/gcc-patches/2018-10/msg02079.html

Quuxplusone commented 4 years ago

Bill's RFC: https://lists.llvm.org/pipermail/llvm-dev/2020-August/144082.html

Quuxplusone commented 3 years ago

_Bug 49902 has been marked as a duplicate of this bug._

Quuxplusone commented 3 years ago

This feature exists in GCC since version 11:

-fzero-call-used-regs=[skip|used-gpr|all-gpr|used|all]

The kernel supports the use of =used-gpr since v5.15 as CONFIG_ZERO_CALL_USED_REGS:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/security/Kconfig.hardening?h=v5.15-rc1#n232