[PATCH] D46585: Align ClearShadowForThreadStackAndTLS for NetBSD/i386

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 09:31:38 PDT 2018


krytarowski created this revision.
krytarowski added reviewers: vitalybuka, joerg.
krytarowski added a project: Sanitizers.
Herald added subscribers: llvm-commits, kubamracek.

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>


Repository:
  rL LLVM

https://reviews.llvm.org/D46585

Files:
  lib/asan/asan_thread.cc


Index: lib/asan/asan_thread.cc
===================================================================
--- lib/asan/asan_thread.cc
+++ lib/asan/asan_thread.cc
@@ -300,8 +300,11 @@
 
 void AsanThread::ClearShadowForThreadStackAndTLS() {
   PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0);
-  if (tls_begin_ != tls_end_)
-    PoisonShadow(tls_begin_, tls_end_ - tls_begin_, 0);
+  if (tls_begin_ != tls_end_aligned) {
+    uptr tls_begin_aligned = RoundDownTo(tls_begin_, SHADOW_GRANULARITY);
+    uptr tls_end_aligned = RoundUpTo(tls_end_, SHADOW_GRANULARITY);
+    PoisonShadow(tls_begin_aligned, tls_end_aligned - tls_begin_aligned, 0);
+  }
 }
 
 bool AsanThread::GetStackFrameAccessByAddr(uptr addr,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46585.145705.patch
Type: text/x-patch
Size: 710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/ac84cc84/attachment.bin>


More information about the llvm-commits mailing list