Skip to content

Commit

Permalink
[ELF][AArch64] Fix potentially corrupted section content for PAC
Browse files Browse the repository at this point in the history
D74537 introduced a bug: if `(config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_PAC) != 0`
with -z pac-plt unspecified, we incorrectly use AArch64BtiPac, whose writePlt will make
out-of-bounds write after the .plt section. This is often benign because the
output section after .plt will usually overwrite the content.

This is very difficult to test without D131247 (Parallelize writes of different OutputSections).
  • Loading branch information
MaskRay committed Aug 6, 2022
1 parent e89d6d2 commit d7cbfcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lld/ELF/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,8 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
}

static TargetInfo *getTargetInfo() {
if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
if ((config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ||
config->zPacPlt) {
static AArch64BtiPac t;
return &t;
}
Expand Down

0 comments on commit d7cbfcf

Please sign in to comment.