[libcxx-commits] [PATCH] D132522: [1b/3][compiler-rt][ASan] API for annotating objects memory

Tacet via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 21 19:08:34 PDT 2022


AdvenamTacet updated this revision to Diff 462065.
AdvenamTacet added a comment.

Correct revision update, previous files are for deque...

Is there any way to automate updates to not make mistakes writing numbers?
To avoid writing `arc diff --update <id>`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132522/new/

https://reviews.llvm.org/D132522

Files:
  compiler-rt/lib/asan/asan_poisoning.cpp


Index: compiler-rt/lib/asan/asan_poisoning.cpp
===================================================================
--- compiler-rt/lib/asan/asan_poisoning.cpp
+++ compiler-rt/lib/asan/asan_poisoning.cpp
@@ -354,8 +354,8 @@
   uptr old_mid = reinterpret_cast<uptr>(old_mid_p);
   uptr new_mid = reinterpret_cast<uptr>(new_mid_p);
   uptr granularity = ASAN_SHADOW_GRANULARITY;
-  if (!(beg <= old_mid && beg <= new_mid && old_mid <= end && new_mid <= end &&
-        IsAligned(beg, granularity))) {
+  if (!IsAligned(beg, granularity)) return;
+  if (!(beg <= old_mid && beg <= new_mid && old_mid <= end && new_mid <= end)) {
     GET_STACK_TRACE_FATAL_HERE;
     ReportBadParamsToAnnotateContiguousContainer(beg, end, old_mid, new_mid,
                                                  &stack);
@@ -389,6 +389,11 @@
   PoisonShadow(b2, c - b2, kAsanContiguousContainerOOBMagic);
   if (b1 != b2) {
     CHECK_EQ(b2 - b1, granularity);
+    // If in [b1; b2) there is not poisoned byte outside of container,
+    // we cannot modify last granule.
+    // That may happen for example when object poisons own memory.
+    uptr accessible = *(u8*)MemToShadow(b1) == 0 ? granularity : *(u8*)MemToShadow(b1);
+    if(*(u8*)MemToShadow(b1) < granularity && end < (b1 + accessible) ) return;
     *(u8*)MemToShadow(b1) = static_cast<u8>(new_mid - b1);
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132522.462065.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220922/06a68a1e/attachment-0001.bin>


More information about the libcxx-commits mailing list