[compiler-rt] r255725 - [cfi] Fix shadow sanity check.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 16:18:04 PST 2015


Author: eugenis
Date: Tue Dec 15 18:18:04 2015
New Revision: 255725

URL: http://llvm.org/viewvc/llvm-project?rev=255725&view=rev
Log:
[cfi] Fix shadow sanity check.

The current check may break if the starting address in fill_shadow is
not page-aligned.

Modified:
    compiler-rt/trunk/lib/cfi/cfi.cc

Modified: compiler-rt/trunk/lib/cfi/cfi.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/cfi.cc?rev=255725&r1=255724&r2=255725&view=diff
==============================================================================
--- compiler-rt/trunk/lib/cfi/cfi.cc (original)
+++ compiler-rt/trunk/lib/cfi/cfi.cc Tue Dec 15 18:18:04 2015
@@ -88,11 +88,12 @@ static void fill_shadow(uptr begin, uptr
     *s = sv;
 
   // Sanity checks.
-  for (; p < end; p += kShadowAlign) {
-    assert((uptr)ShadowValue::load(p).get_cfi_check() == cfi_check);
-    assert((uptr)ShadowValue::load(p + kShadowAlign / 2).get_cfi_check() ==
+  uptr q = p & ~(kShadowAlign - 1);
+  for (; q < end; q += kShadowAlign) {
+    assert((uptr)ShadowValue::load(q).get_cfi_check() == cfi_check);
+    assert((uptr)ShadowValue::load(q + kShadowAlign / 2).get_cfi_check() ==
            cfi_check);
-    assert((uptr)ShadowValue::load(p + kShadowAlign - 1).get_cfi_check() ==
+    assert((uptr)ShadowValue::load(q + kShadowAlign - 1).get_cfi_check() ==
            cfi_check);
   }
 }




More information about the llvm-commits mailing list