[compiler-rt] r259007 - [cfi] Fix recovery from out-of-bounds vtable error.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 22:27:46 PST 2016
On Wed, Jan 27, 2016 at 4:37 PM, Evgeniy Stepanov via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: eugenis
> Date: Wed Jan 27 18:37:54 2016
> New Revision: 259007
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259007&view=rev
> Log:
> [cfi] Fix recovery from out-of-bounds vtable error.
>
> Modified:
> compiler-rt/trunk/lib/cfi/cfi.cc
> compiler-rt/trunk/test/cfi/cross-dso/target_out_of_bounds.cpp
>
> Modified: compiler-rt/trunk/lib/cfi/cfi.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/cfi/cfi.cc?rev=259007&r1=259006&r2=259007&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/cfi/cfi.cc (original)
> +++ compiler-rt/trunk/lib/cfi/cfi.cc Wed Jan 27 18:37:54 2016
> @@ -306,12 +306,14 @@ ALWAYS_INLINE void CfiSlowPathCommon(u64
> // FIXME: call the ubsan handler if DiagData != nullptr?
> VReport(1, "CFI: invalid memory region for a check target: %p\n",
> Ptr);
> #ifdef CFI_ENABLE_DIAG
> - if (DiagData)
> + if (DiagData) {
> __ubsan_handle_cfi_check_fail(
> reinterpret_cast<__ubsan::CFICheckFailData *>(DiagData),
> reinterpret_cast<uptr>(Ptr));
> - else
> + return;
> + } else {
>
Drop the else-after-return, and possibly invert to reduce indentation:
if (!DiagData)
Trap();
__ubsaN-handle_...
> Trap();
> + }
> #else
> Trap();
> #endif
> @@ -348,7 +350,8 @@ void InitializeFlags() {
>
> SetVerbosity(common_flags()->verbosity);
>
> - if (Verbosity()) ReportUnrecognizedFlags();
> + if (Verbosity())
> + ReportUnrecognizedFlags();
>
> if (common_flags()->help) {
> cfi_parser.PrintFlagDescriptions();
>
> Modified: compiler-rt/trunk/test/cfi/cross-dso/target_out_of_bounds.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/cfi/cross-dso/target_out_of_bounds.cpp?rev=259007&r1=259006&r2=259007&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/cfi/cross-dso/target_out_of_bounds.cpp
> (original)
> +++ compiler-rt/trunk/test/cfi/cross-dso/target_out_of_bounds.cpp Wed Jan
> 27 18:37:54 2016
> @@ -20,9 +20,13 @@ int main(int argc, char *argv[]) {
> // enough to handle unaddressable vtables. TODO: fix this.
> void *empty = calloc(1, 128);
> uintptr_t v = (uintptr_t)empty + 64;
> - A *volatile p = new A();
> - for (uintptr_t *q = (uintptr_t *)p; q < (uintptr_t *)(p + 1); ++q)
> + char *volatile p = reinterpret_cast<char *>(new A());
> + for (uintptr_t *q = (uintptr_t *)p; q < (uintptr_t *)(p + sizeof(A));
> ++q)
> *q = v;
> +
> + // CHECK: runtime error: control flow integrity check for type 'A'
> failed during cast
> + A *volatile pa = reinterpret_cast<A *>(p);
> +
> // CHECK: untime error: control flow integrity check for type 'A'
> failed during virtual call
> - p->f();
> + pa->f();
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160127/618af8d3/attachment.html>
More information about the llvm-commits
mailing list