This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] - return address signing
ClosedPublic

Authored by LukeCheeseman on Jul 25 2018, 5:46 AM.

Details

Summary

Add a command line options -msign-return-address to enable return address signing

  • Armv8.3a added instructions to sign the return address to help mitigate against ROP attacks
  • This patch adds command line options to generate function attributes that signal to the back whether return address signing instructions should be added

Diff Detail

Repository
rL LLVM

Event Timeline

LukeCheeseman created this revision.Jul 25 2018, 5:46 AM
LukeCheeseman set the repository for this revision to rC Clang.

Maybe you can provide some more context to this patch (why you need this, or point to some document), if possible.

include/clang/Frontend/CodeGenOptions.h
111 ↗(On Diff #157241)

Please conform this to the code around (i.e. each option on a separate line with comments explaining the option).

test/CodeGen/aarch64-sign-return-address.c
5 ↗(On Diff #157241)

Can the label check not be under one 'CHECK' prefix?

LukeCheeseman edited the summary of this revision. (Show Details)
LukeCheeseman marked 2 inline comments as done.
kcc added inline comments.Jul 25 2018, 1:27 PM
include/clang/Frontend/CodeGenOptions.h
114 ↗(On Diff #157266)

what's the purpose of signing LR if it is not spilled?

Change codegen option partial to non-leaf to match msign-return-address scope values

LukeCheeseman added inline comments.Jul 26 2018, 3:31 AM
include/clang/Frontend/CodeGenOptions.h
114 ↗(On Diff #157266)

Assuming you are in a context where you have managed to gain control of the flow of execution. If you don't sign functions that spill LR then those functions become good candidates for finding gadgets as now execution can start from any point in that function.

Move -msign-return-address argument handling into AArch64TargetArgs

olista01 accepted this revision.Aug 17 2018, 5:36 AM
olista01 added a subscriber: olista01.

LGTM, thanks!

This revision is now accepted and ready to land.Aug 17 2018, 5:36 AM
This revision was automatically updated to reflect the committed changes.
hctim added a subscriber: hctim.Jan 20 2020, 4:31 PM
This comment was removed by hctim.
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2020, 4:31 PM