This is an archive of the discontinued LLVM Phabricator instance.

Implement bad cast checks using control flow integrity information.
ClosedPublic

Authored by pcc on Mar 12 2015, 11:31 PM.

Details

Summary

This scheme checks that pointer and lvalue casts are made to an object of
the correct dynamic type; that is, the dynamic type of the object must be
a derived class of the pointee type of the cast. The checks are currently
only introduced where the class being casted to is a polymorphic class.

Diff Detail

Event Timeline

pcc updated this revision to Diff 21898.Mar 12 2015, 11:31 PM
pcc retitled this revision from to Implement bad cast checks using control flow integrity information..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added reviewers: kcc, jfb.
pcc added a subscriber: Unknown Object (MLST).
jfb added inline comments.Mar 13 2015, 10:04 AM
docs/UsersManual.rst
974

Add -fsanitize=cfi-cast-strict?

lib/CodeGen/CGClass.cpp
2121

Why?

test/CodeGenCXX/cfi-cast.cpp
4

Could you have a quick blurb that helps decipher the metadata !"1B' part, explaining that it's the important bit in the checks.

15

CHECK-LABEL-DCAST (same below).

77

Add rvalue ref test?

A a();

B rvalue() {
  return static_cast<B&&>(a());
}
kcc edited edge metadata.Mar 13 2015, 12:47 PM

Please also add compiler-rt test(s)

docs/UsersManual.rst
971

Don't we want more verbose names?
cfi-polymorphic-base-downcast
cfi-void-to-polymorphic-cast
or something.

pcc updated this revision to Diff 21967.Mar 13 2015, 3:45 PM
pcc edited edge metadata.
  • Address reviewer comments
pcc added a comment.Mar 13 2015, 3:46 PM

Please also add compiler-rt test(s)

Will do

docs/UsersManual.rst
971

Okay, I've given these better names.

974

Done.

lib/CodeGen/CGClass.cpp
2121

Explained in comment.

test/CodeGenCXX/cfi-cast.cpp
4

Done

15

Done

77

Done.

jfb edited edge metadata.Mar 13 2015, 7:24 PM

lgtm after what seems like a typo.

test/CodeGenCXX/cfi-cast.cpp
59

B&&

This revision was automatically updated to reflect the committed changes.