Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarch64: enable PAC/BTI #15

Closed

Commits on Sep 6, 2024

  1. aarch64: enable PAC/BTI

    Enable Pointer Authentication Codes (PAC) and Branch Target
    Identification (BTI) support for ARM 64 targets.
    
    PAC works by signing the LR with either an A key or B key and verifying
    the return address. Since the assembly code does not push and pop the
    link register to the stack, and it remains in the register file, their
    is no need to sign the LR, so PAC is essentially just adding it to the
    GNU notes section for auditing purposes.
    
    BTI works by marking all call and jump positions with bti c and bti
    j instructions. If execution control transfers via an indirect branch
    or call to an instruction other than a BTI instruction, the execution
    is killed via SIGILL.
    
    For BTI to work, all object files linked for a unit of execution,
    whether an executable or a library must have the GNU Notes section of
    the ELF file marked to indicate BTI support. This is so loader/linkers
    can apply the proper permission bits (PROT_BRI) on the memory region.
    
    PAC can also be annotated in the GNU ELF notes section, but it's not
    required for enablement, as interleaved PAC and non-pac code works as
    expected since it's the callee that performs all the checking.
    
    Becuase the aarch64 assembly code does not make use of pushing the LR to
    the stack, only BTI targets were needed to be instrumented and the GNU
    notes section indicating support for BTU. Thus for PAC the only
    requirement was to mark the GNU notes section as supporting PAC.
    
    Testing was done under the following CFLAGS and CXXFLAGS for all
    combinations:
    1. -mbranch-protection=none
    2. -mbranch-protection=standard
    3. -mbranch-protection=pac-ret
    4. -mbranch-protection=pac-ret+b-key
    5. -mbranch-protection=bti
    
    Signed-off-by: Bill Roberts <[email protected]>
    billatarm committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    3348c23 View commit details
    Browse the repository at this point in the history