This is an archive of the discontinued LLVM Phabricator instance.

Expose __hwasan_tag_mismatch_stub
ClosedPublic

Authored by mmalcomson on Oct 17 2019, 8:47 AM.

Details

Summary

GCC would like to emit a function call to report a tag mismatch
rather than hard-code the brk instruction directly.

__hwasan_tag_mismatch_stub contains most of the functionality to do
this already, but requires exposure in the dynamic library.

This patch moves __hwasan_tag_mismatch_stub outside of the anonymous
namespace that it was defined in and declares it in
hwasan_interface_internal.h.

We also add the ability to pass sizes larger than 16 bytes to this
reporting function by providing a fourth parameter that is only looked
at when the size provided is not in the original accepted range.

This does not change the behaviour where it is already being called,
since the previous definition only accepted sizes up to 16 bytes and
hence the change in behaviour is not seen by existing users.
The change in declaration does not matter, since the only existing use
is in the __hwasan_tag_mismatch function written in assembly.

Tested with gcc and clang on an AArch64 vm.

Diff Detail

Event Timeline

mmalcomson created this revision.Oct 17 2019, 8:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2019, 8:47 AM
eugenis added inline comments.Oct 17 2019, 2:27 PM
compiler-rt/lib/hwasan/hwasan_interface_internal.h
115

I think the _stub suffix does not make sense in a public interface function.
How about __hwasan_tag_mismatch4 - where 4 stands for the number of arguments?

compiler-rt/lib/hwasan/hwasan_linux.cpp
486

There is a pre-existing bug here: this function needs to set the is_load member.

eugenis accepted this revision.Oct 18 2019, 3:37 PM

LGTM

This revision is now accepted and ready to land.Oct 18 2019, 3:37 PM
This revision was automatically updated to reflect the committed changes.