[PATCH] Implement bad cast checks using control flow integrity information.

JF Bastien jfb at chromium.org
Fri Mar 13 10:04:51 PDT 2015


================
Comment at: docs/UsersManual.rst:974
@@ -971,1 +973,3 @@
+   -  ``-fsanitize=cfi-vcast``: Cast from ``void*`` or another unrelated
+      type to the wrong dynamic type. Implies ``-flto``.
    -  ``-fsanitize=cfi-vptr``: Use of an object whose vptr is of the
----------------
Add `-fsanitize=cfi-cast-strict`?

================
Comment at: lib/CodeGen/CGClass.cpp:2121
@@ +2120,3 @@
+    if (MD->isVirtual()) {
+      // Virtual member functions are only ok if they are implicit destructors.
+      if (isa<CXXDestructorDecl>(MD) && MD->isImplicit())
----------------
Why?

================
Comment at: test/CodeGenCXX/cfi-cast.cpp:4
@@ +3,3 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcast,cfi-cast-strict -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-VCAST-STRICT %s
+
+struct A {
----------------
Could you have a quick blurb that helps decipher the `metadata !"1B'` part, explaining that it's the important bit in the checks.

================
Comment at: test/CodeGenCXX/cfi-cast.cpp:15
@@ +14,3 @@
+
+// CHECK-DCAST: define void @_Z3abpP1A
+void abp(A *a) {
----------------
`CHECK-LABEL-DCAST` (same below).

================
Comment at: test/CodeGenCXX/cfi-cast.cpp:77
@@ +76,2 @@
+  static_cast<C*>(p);
+}
----------------
Add rvalue ref test?

```
A a();

B rvalue() {
  return static_cast<B&&>(a());
}
```

http://reviews.llvm.org/D8312

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list