-
Notifications
You must be signed in to change notification settings - Fork 0
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][PAC][lldb] Support PAuth features in user expressions #68
Open
kovdan01
wants to merge
9
commits into
elf-pauth
Choose a base branch
from
dkovalev/pauth-lldb
base: elf-pauth
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kovdan01
force-pushed
the
dkovalev/pauth-lldb
branch
2 times, most recently
from
February 7, 2024 04:29
f85a1a3
to
f39ea06
Compare
kovdan01
force-pushed
the
dkovalev/pauth-lldb
branch
11 times, most recently
from
February 12, 2024 10:58
fd2517e
to
2abc4d2
Compare
…riminated` The Dwarf attribute `DW_AT_LLVM_ptrauth_address_discriminated` was emitted for all ptrauth-qualified types, even if the address discrimination was disabled. This was related to incorrect usage of `std::optional<bool>` holding the value of the attribute.
kovdan01
force-pushed
the
dkovalev/pauth-lldb
branch
2 times, most recently
from
February 12, 2024 17:06
08567db
to
a567cae
Compare
This was
linked to
issues
Feb 12, 2024
kovdan01
changed the title
[WIP][PAC][lldb] Add basic ptrauth handling in lldb user expressions
[AArch64][PAC][lldb] Support PAuth features in user expressions
Feb 12, 2024
…RE_PAUTH` This adds support for `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` feature handling in llvm-readobj and llvm-readelf. The following constants for supported platforms are also introduced: - `GNU_PROPERTY_AARCH64_FEATURE_PAUTH_PLATFORM_INVALID = 0` - `GNU_PROPERTY_AARCH64_FEATURE_PAUTH_PLATFORM_BAREMETAL = 1` - `GNU_PROPERTY_AARCH64_FEATURE_PAUTH_PLATFORM_LINUX = 2` For the linux platform, output of the tools contains descriptions of PAuth features which are enabled/disabled depending on the version value.
Emit PAuth ABI compatibility tag values as llvm module flags: - `aarch64-elf-pauthabi-platform` - `aarch64-elf-pauthabi-version`
Emit `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` property in `.note.gnu.property` section depending on `aarch64-elf-pauthabi-platform` and `aarch64-elf-pauthabi-version` llvm module flags.
- In new PAuth ABI version, support for extra data (except platform and version) is dropped. Change container for holding the tag from `SmallVector<uint8_t>` to `std::optional<std::array<uint8_t, 16>>`. - In new PAuth ABI version, the GNU property section becomes the main way of ELF marking. Support for alternative way is temporarily disabled in this commit unless the corresponding mainline PR and ARM PAuth ABI PR are merged.
…E_PAUTH` Apply signing schema for user expressions when debugging AArch64 ELFs depending on the `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` property in `.note.gnu.property` section in the executable object file. To avoid linking against ObjectFileELF plugin everywhere, define `ParseGNUPropertyAArch64PAuthABI` as a virtual function in the base `ObjectFile` class.
This adds support for `DW_TAG_LLVM_ptrauth_type` entries corresponding to explicitly signed free function pointers in lldb user expressions. In this patch, as a temporary solution pointer auth schema corresponding to `-mbranch-protection=pauthabi` is enabled unconditionally. This also brings support for all kinds of implicitly signed pointers, including member function pointers, virtual function pointers, etc.
…...)]]` attribute - Encode the attribute in Dwarf as a `DW_TAG_LLVM_ptrauth_type` entry corresponding to vtable pointer. The attribute supports "default" values for address and extra discrimination, but in Dwarf we emit actual values due to `DW_AT_LLVM_ptrauth_*` attributes limitations. See lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp for details. - When parsing dynamic class and structure types from Dwarf, check the vtable pointer type against `DW_TAG_LLVM_ptrauth_type`. If true, apply the `clang::ptrauth_vtable_pointer` attribute with corresponding parameters to the class record decl. "Default" address and extra discrimination values are not restored, the actual ones are, but the result is effectively the same since the signing schema must be preserved unchanged.
…attribute Use IR metadata annotations for storing `ptrauth_struct_key` and `ptrauth_struct_disc` values. Corresponding `DW_TAG_LLVM_annotation` tags are used in Dwarf.
kovdan01
force-pushed
the
dkovalev/pauth-lldb
branch
from
February 16, 2024 17:37
ee59834
to
3a04a18
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains changes related to PAuth support in lldb (particularly, in lldb user expressions).
For implicitly signed stuff, we rely on correct
LangOptions
. They are set depending on theGNU_PROPERTY_AARCH64_FEATURE_PAUTH
value, so the PR includes its support implementation at all levels. See:For explicitly signed stuff, we still need to set
LangOptions
properly, but we also need to parse the explicit signing schema from Dwarf. See:__ptrauth
-qualified pointers: 8e62fa8[[clang::ptrauth_vtable_pointer(...)]]
attribute: 8ed84bc[[clang::ptrauth_struct(...)]]
attribute: 3a04a18Any prefix of the patch series can be merged independently of the remaining suffix - when reset to any of the commits, all tests still pass and the functionality implemented in the commits from the prefix of the series works.
The PR contains tests for all the changes, but manual testing is also used since lldb unit tests might not be enough (at least unless we have lldb shell lit tests). See C/C++ code under spoilers and lldb session output while debugging corresponding executables below.
Free function pointer
source
lldb session
Member function pointer
source
lldb session
Virtual table pointer and virtual function pointer
source
lldb session
TODO: