This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][hwasan] Let CheckAddressSized eventually call HandleTagMismatch on Fuchsia
ClosedPublic

Authored by leonardchan on Dec 5 2022, 4:11 PM.

Details

Summary

Any hwasan tag checking done through runtime calls like __hwasan_mem* or __hwasan_load/store* currently raise a sigtrap on a tag mismatch. Hwasan dumps as much information it knows on the tag mismatch by placing important values in specific registers before the brk and encoding the access information in the optional argument supplied to the brk. If the platform hwasan runs on uses signal handlers, then users can see the typical pretty hwasan error report, but Fuchsia doesn't use signal handlers, so it's left up to the platform exception handler to print all this encoded information.

This patch attempts to enter the regular error reporting path via HandleTagMismatch if a new macro CAN_GET_REGISTERS is set. For now this is only defined for Fuchsia + aarch64, but can be expanded for other platforms.

Diff Detail

Event Timeline

leonardchan created this revision.Dec 5 2022, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 4:11 PM
leonardchan requested review of this revision.Dec 5 2022, 4:11 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptDec 5 2022, 4:11 PM

Not sure if there can be an upstream test for this since we don't have any fuchsia emulators running on buildbot. I imagine for now we don't want to change the current behavior on linux where each signal handler can be enabled/disabled via the handle_sig* env options.

vitalybuka accepted this revision.Dec 7 2022, 2:10 PM
This revision is now accepted and ready to land.Dec 7 2022, 2:10 PM
vitalybuka added inline comments.Dec 7 2022, 2:12 PM
compiler-rt/lib/hwasan/hwasan_checks.h
90–104

Here are else #if SANITIZER_FUCHSIA is probably more appropriate
we are doing this not because regs are available, but because we can't do int3, fuchsia specific

leonardchan marked an inline comment as done.Dec 7 2022, 3:10 PM