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).

(cherry picked from commit d7cbfcf)
  • Loading branch information
MaskRay authored and tstellar committed Aug 8, 2022
1 parent 9383f82 commit bf27137
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 @@ -873,8 +873,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 bf27137

Please sign in to comment.