CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
103 lines
3.5 KiB
C++
103 lines
3.5 KiB
C++
// RUN: mkdir -p %t.dir && cd %t.dir
|
|
// RUN: %clangxx_cfi_dso -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %expect_crash %t.dir/exe 2>&1 | FileCheck --check-prefix=CFI %s
|
|
// RUN: %expect_crash %t.dir/exe x 2>&1 | FileCheck --check-prefix=CFI-CAST %s
|
|
|
|
// RUN: %clangxx_cfi_dso -DB32 -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso -DB32 %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %expect_crash %t.dir/exe 2>&1 | FileCheck --check-prefix=CFI %s
|
|
// RUN: %expect_crash %t.dir/exe x 2>&1 | FileCheck --check-prefix=CFI-CAST %s
|
|
|
|
// RUN: %clangxx_cfi_dso -DB64 -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso -DB64 %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %expect_crash %t.dir/exe 2>&1 | FileCheck --check-prefix=CFI %s
|
|
// RUN: %expect_crash %t.dir/exe x 2>&1 | FileCheck --check-prefix=CFI-CAST %s
|
|
|
|
// RUN: %clangxx_cfi_dso -DBM -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso -DBM %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %expect_crash %t.dir/exe 2>&1 | FileCheck --check-prefix=CFI %s
|
|
// RUN: %expect_crash %t.dir/exe x 2>&1 | FileCheck --check-prefix=CFI-CAST %s
|
|
|
|
// RUN: %clangxx -DBM -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx -DBM %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %t.dir/exe 2>&1 | FileCheck --check-prefix=NCFI %s
|
|
// RUN: %t.dir/exe x 2>&1 | FileCheck --check-prefix=NCFI %s
|
|
|
|
// RUN: %clangxx -DBM -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso -DBM %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %t.dir/exe 2>&1 | FileCheck --check-prefix=NCFI %s
|
|
// RUN: %t.dir/exe x 2>&1 | FileCheck --check-prefix=NCFI %s
|
|
|
|
// RUN: %clangxx_cfi_dso_diag -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
|
|
// RUN: %clangxx_cfi_dso_diag %s -o %t.dir/exe %ld_flags_rpath_exe
|
|
// RUN: %t.dir/exe 2>&1 | FileCheck --check-prefix=CFI-DIAG-CALL %s
|
|
// RUN: %t.dir/exe x 2>&1 | FileCheck --check-prefix=CFI-DIAG-CALL --check-prefix=CFI-DIAG-CAST %s
|
|
|
|
// Tests that the CFI mechanism crashes the program when making a virtual call
|
|
// to an object of the wrong class but with a compatible vtable, by casting a
|
|
// pointer to such an object and attempting to make a call through it.
|
|
|
|
// REQUIRES: cxxabi
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
struct A {
|
|
virtual void f();
|
|
};
|
|
|
|
void *create_B();
|
|
|
|
#ifdef SHARED_LIB
|
|
|
|
#include "../utils.h"
|
|
struct B {
|
|
virtual void f();
|
|
};
|
|
void B::f() {}
|
|
|
|
void *create_B() {
|
|
create_derivers<B>();
|
|
return (void *)(new B());
|
|
}
|
|
|
|
#else
|
|
|
|
void A::f() {}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
void *p = create_B();
|
|
A *a;
|
|
|
|
// CFI: =0=
|
|
// CFI-CAST: =0=
|
|
// NCFI: =0=
|
|
fprintf(stderr, "=0=\n");
|
|
|
|
if (argc > 1 && argv[1][0] == 'x') {
|
|
// Test cast. BOOM.
|
|
// CFI-DIAG-CAST: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type
|
|
// CFI-DIAG-CAST-NEXT: note: vtable is of type '{{(struct )?}}B'
|
|
a = (A*)p;
|
|
} else {
|
|
// Invisible to CFI. Test virtual call later.
|
|
memcpy(&a, &p, sizeof(a));
|
|
}
|
|
|
|
// CFI: =1=
|
|
// CFI-CAST-NOT: =1=
|
|
// NCFI: =1=
|
|
fprintf(stderr, "=1=\n");
|
|
|
|
// CFI-DIAG-CALL: runtime error: control flow integrity check for type 'A' failed during virtual call
|
|
// CFI-DIAG-CALL-NEXT: note: vtable is of type '{{(struct )?}}B'
|
|
a->f(); // UB here
|
|
|
|
// CFI-NOT: =2=
|
|
// CFI-CAST-NOT: =2=
|
|
// NCFI: =2=
|
|
fprintf(stderr, "=2=\n");
|
|
}
|
|
#endif
|