Skip to content

[pauthabielf64] Allow relocatable objects to request PLT GOT signing #294

@kovdan01

Description

@kovdan01

A pauth-enabled environment comes with a set of pauth features enabled by default. One of the features such environment might include is PLT GOT signing. Currently, it requires a special option being passed to a linker (-z pac-plt in case of lld). If the linker is invoked from the compiler driver, this option can be automatically applied to linker's command line arguments when a pauth-enabled environment including PLT GOT signing is requested - say, when compiling with -target aarch64-unknown-linux-mypauthenv. However, if we first compile to object files, and then invoke the linker separately (which is a very common approach), the user has to pass -z pac-plt to the linker manually, which makes usage of pauth-enabled environment not transparent.

To keep transparency in this case, we need to somehow request PLT GOT signing without passing -z pac-plt manually. So, we need to somehow encode this request into relocatable objects files passed to the linker as an input. Essentially, it would be ideal to use smth like dynamic array tags but for static linking - unfortunately, it looks like that no direct alternative is available. Possible implementations include the following.

  1. Defining a new GNU property like GNU_PROPERTY_AARCH64_FORCE_PAC_PLT. This looks as the most applicable way to me. The new property might hold a single integer value with non-zero meaning signed PLT GOT requested and zero
    meaning usual unsigned PLT GOT should be used.

    Pros: The GNU property section is already pretty widely used for various AArch64 info (see GNU_PROPERTY_AARCH64_FEATURE_1_AND and GNU_PROPERTY_AARCH64_FEATURE_PAUTH properties). Using a separate property
    for this particular purpose makes it easy for every pauth-enabled environment to adopt this way of requesting PLT GOT signing.

    Cons: need to decide how to handle files w/o the property, for example, objects compiled from raw assembly files which were not modified to include this property. I think the same way as for missing PAuth core info might be
    used - see -z pauth-report=none|warning|error: [lld][AArch64][ELF][PAC] Support AUTH relocations and AUTH ELF marking llvm/llvm-project#72714

  2. Using build attributes AArch64 build attributes specification #230. Once merged, this looks like the most suitable option for encoding PLT GOT signing request.

  3. Using PAuth core info and encoding the PLT GOT signing request in (platform,version) tuple.

    Pros: no need for new entities, PAuth core info is already defined and its initial support is already present in llvm.

    Cons: meaning of the version value is defined by platform, and for each new platform, if it wants to support PLT GOT signing, we'll need to teach linker about meaning of particular (platform,version) value. I think that
    a linker should treat (platform,version) tuple as an opaque value with no meaning other than a) (0,0) - explicitly pauth-disabled; b) different tuples in input files - link error. IMHO, this makes using PAuth core info discouraged for the desired purpose.

  4. Using new AUTH relocation types like R_AARCH64_CALL26 -> R_AARCH64_AUTH_CALL26, R_AARCH64_CONDBR19 -> R_AARCH64_AUTH_CONDBR19, R_AARCH64_JUMP26 -> R_AARCH64_AUTH_JUMP26, R_AARCH64_TSTBR14 -> R_AARCH64_AUTH_TSTBR14.

    Pros: ?

    Cons: requires many new AUTH relocation types (at least 4, as far as I see from lld's sources). This will also cause some pain with handling mix of signed/unsigned PLT-generating relocations in one object file. Since PLT GOT signing is a per-link-job decision, putting the signing request into individual relocations looks as a bad decision - having one place encoding the request in each input object file looks better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions