Skip to content

[lldb] Fix size of write when querying ptr auth mask #7301

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

Merged

Conversation

augusto2112
Copy link

According to the MemoryReader documentation, querying the pointer authentication mask should treat the out buffer as pointer-sized in the target process:

  /// The query should ignore inBuffer, and treat outBuffer as pointer-sized
  /// buffer (the size of a target pointer, not a swift_addr_t) which should be
  /// populated with the mask of pointer addressable bits.
  DLQ_GetPtrAuthMask,

LLDB was mistakenly treating the buffer as 8 bytes long.

rdar://114237716

According to the MemoryReader documentation, querying the pointer
authentication mask should treat the out buffer as pointer-sized in the
target process:

```
  /// The query should ignore inBuffer, and treat outBuffer as pointer-sized
  /// buffer (the size of a target pointer, not a swift_addr_t) which should be
  /// populated with the mask of pointer addressable bits.
  DLQ_GetPtrAuthMask,
```

LLDB was mistakenly treating the buffer as 8 bytes long.

rdar://114237716
@augusto2112
Copy link
Author

@swift-ci test

@@ -29,7 +29,7 @@ bool LLDBMemoryReader::queryDataLayout(DataLayoutQueryType type, void *inBuffer,
// disk. Setting the bit in the mask ensures it isn't accidentally cleared
// by ptrauth stripping.
mask_pattern |= LLDB_FILE_ADDRESS_BIT;
memcpy(outBuffer, &mask_pattern, sizeof(uint64_t));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long-term question: Could we change the API vended by the Swift runtime here to at least include a size parameter or is this stable API?

@adrian-prantl adrian-prantl merged commit 2631202 into swiftlang:swift/release/5.9 Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants