This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][hwasan] Factor out CanUseTaggingAbi() and EnableTaggingAbi()
ClosedPublic

Authored by glider on Aug 24 2022, 3:29 AM.

Details

Summary

Simplify InitializeOsSupport() by separating code for detecting and
enabling the tagged address ABI.

Also drop the unnecessary errno checks (regardless of errno value, we
cannot assume that tagging works if the system call failed) and ensure
prctl(PR_SET_TAGGED_ADDR_CTRL) is only called on Android, not on x86
(where arch_prctl(ARCH_ENABLE_TAGGED_ADDR, kTagBits) is used).

Depends on D132544

Diff Detail

Event Timeline

glider created this revision.Aug 24 2022, 3:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 3:29 AM
glider requested review of this revision.Aug 24 2022, 3:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 3:29 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
kstoimenov added inline comments.Aug 24 2022, 1:35 PM
compiler-rt/lib/hwasan/hwasan_linux.cpp
146

Is the '-' in front of EINVAL intentional?

147–148

Looks like the previous version of the code checked for 'local_errno == EINVAL' and this one doesn't. Is that expected?

kstoimenov requested changes to this revision.Aug 24 2022, 1:40 PM
This revision now requires changes to proceed.Aug 24 2022, 1:40 PM
glider added inline comments.Aug 24 2022, 2:23 PM
compiler-rt/lib/hwasan/hwasan_linux.cpp
146

Yes, see https://lore.kernel.org/all/20220815041803.17954-1-kirill.shutemov@linux.intel.com/
Syscalls usually return negative errno values.

147–148

Right, this is intentional, see the comments here: https://reviews.llvm.org/D132467

vitalybuka added inline comments.Aug 24 2022, 2:27 PM
compiler-rt/lib/hwasan/hwasan_linux.cpp
142

checking actual ARCH_GET_UNTAG_MASK like line 151 would be nice
separate patch is find

147–148

yes, we disscussed that on another review
also do we need to check error at all if we have line: 151

vitalybuka accepted this revision.Aug 24 2022, 2:27 PM
This revision is now accepted and ready to land.Aug 24 2022, 2:34 PM
This revision was landed with ongoing or failed builds.Aug 25 2022, 1:45 AM
This revision was automatically updated to reflect the committed changes.