Skip to content

Commit 993555b

Browse files
committed
[compiler-rt][scudo] Check for failing prctl call
A bunch of MTE tests like ./ScudoUnitTest-aarch64-Test/MemtagTest.StoreTags can fail on aarch64-linux if the kernel doesn't support the tagged address ABI. It looks like the call to prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0) can return -1, which casted to an unsigned int and masked will return a value not equal to PR_MTE_TCF_NONE, meaning systemDetectsMemoryTagFaultsTestOnly can return an incorrect value. This updates the check to account for a failing prctl call. Differential Revision: https://reviews.llvm.org/D110888
1 parent 30001af commit 993555b

File tree

1 file changed

+4
-3
lines changed
  • compiler-rt/lib/scudo/standalone

1 file changed

+4
-3
lines changed

compiler-rt/lib/scudo/standalone/memtag.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ inline bool systemDetectsMemoryTagFaultsTestOnly() {
9191
#ifndef PR_MTE_TCF_MASK
9292
#define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT)
9393
#endif
94-
return (static_cast<unsigned long>(
95-
prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0)) &
96-
PR_MTE_TCF_MASK) != PR_MTE_TCF_NONE;
94+
int res = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
95+
if (res == -1)
96+
return false;
97+
return (static_cast<unsigned long>(res) & PR_MTE_TCF_MASK) != PR_MTE_TCF_NONE;
9798
}
9899

99100
inline void enableSystemMemoryTaggingTestOnly() {

0 commit comments

Comments
 (0)