This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Apply kTagMask on kFallbackFreeTag
AbandonedPublic

Authored by hjl.tools on Oct 2 2021, 10:52 AM.

Details

Summary

Apply kTagMask, which is 0x3F for Intel LAM, on kFallbackFreeTag (0xBC)
if not in alias mode. Apply kTagMask in alias mode will lead to

hwasan_allocator.cpp:286:38: error: static assertion failed: fallback tag must n
ot be a short granule tag.

286 |       static_assert(kFallbackFreeTag >= kShadowAlignment,

due to

constexpr unsigned kTagBits = 3;
...
constexpr uptr kTagMask = (1UL << kTagBits) - 1; 0x7
...
constexpr uptr kShadowScale = 4;
constexpr uptr kShadowAlignment = 1ULL << kShadowScale;
0x10
...
static constexpr tag_t kFallbackFreeTag = 0xBC & kTagMask; // 0x4

Diff Detail

Event Timeline

hjl.tools requested review of this revision.Oct 2 2021, 10:52 AM
hjl.tools created this revision.

I deliberately chose not to mask the fallback tag.

It's never valid to access freed memory anyway, so we can keep a full 8 bit tag to reduce the chance of a false negative.

hjl.tools abandoned this revision.Oct 4 2021, 6:37 AM

I deliberately chose not to mask the fallback tag.

It's never valid to access freed memory anyway, so we can keep a full 8 bit tag to reduce the chance of a false negative.

Drop this patch then.