This is an archive of the discontinued LLVM Phabricator instance.

Align ClearShadowForThreadStackAndTLS for NetBSD/i386
ClosedPublic

Authored by krytarowski on May 8 2018, 9:31 AM.

Details

Summary

The static TLS vector for the main thread on NetBSD/i386 can be
unaligned in terms of the shadow granularity. Align the start of it with
Round Down and end of it with Round Up operations for the shadow
granularity shift.

Example static TLS vector ranges on NetBSD/i386:
tls_begin_=0xfbee7244 tls_end_=0xfbee726c.

ClearShadowForThreadStackAndTLS() is called from the Main Thread
bootstrap functions.

This change restores the NetBSD x86 32-bit (i386) support.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.May 8 2018, 9:31 AM
joerg added a comment.May 9 2018, 6:32 AM

This looks sensible, but I don't know what PoisonShadow will do for the rest of the memory block.

vitalybuka added a comment.EditedMay 10 2018, 11:24 AM

01-07 shadow values are used for partially addressable blocks. Problem that only lowest bytes can be addressable, and highest are poisoned. So you must to alight tls_begin_.
But you don't have to do so fo the tls_end_, it will be handled by partial values.

I need to align both in order to make it to work.

Otherwise, I'm observing:

==28177==AddressSanitizer CHECK failed: /public/llvm/projects/compiler-rt/lib/asan/asan_poisoning.cc:38 "((AddrIsAlignedByGranularity(addr + size))) != (0)" (0x0, 0x0)

I see.
following should work, but I don't insist

FastPoisonShadowPartialRightRedzone(tls_begin_aligned, tls_end_ - tls_begin_aligned, tls_end_aligned - tls_end_, 0 /*does not matter, should not be used*/)

I need to align both in order to make it to work.

Otherwise, I'm observing:

==28177==AddressSanitizer CHECK failed: /public/llvm/projects/compiler-rt/lib/asan/asan_poisoning.cc:38 "((AddrIsAlignedByGranularity(addr + size))) != (0)" (0x0, 0x0)
vitalybuka accepted this revision.May 11 2018, 10:34 AM
This revision is now accepted and ready to land.May 11 2018, 10:34 AM
This revision was automatically updated to reflect the committed changes.