[compiler-rt] r273464 - [asan] Add a test case for global registration
Ryan Govostes via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 16:33:32 PDT 2016
The error makes it look like the test does not generate an ASAN violation when we dlopen() a shared library and then perform a global buffer overflow on a symbol within that library.
not /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp 3 2>&1 | FileCheck --check-prefix ASAN-CHECK-3 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
I'm assuming the dlopen or dlsym call fails. Are those restricted on Android? I can split that off into a separate test and make it XFAIL if so. Otherwise if there is something else I need to be aware of with Android tests to make this work, please let me know.
I've committed a version that logs output if dl* fails, r273629.
Ryan
> On Jun 23, 2016, at 15:51, Mike Aizatsky <aizatsky at google.com> wrote:
>
> Ryan,
>
> This test breaks the bot:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24502 <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24502>
>
> @@@BUILD_STEP run asan lit tests [arm/hammerhead-userdebug/LMY48T]@@@
> + echo @@@BUILD_STEP run asan lit tests '[arm/hammerhead-userdebug/LMY48T]@@@'
> + cd /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm
> + ninja check-asan
> [1/1] Running the AddressSanitizer tests
> -- Testing: 364 tests, 16 threads --
> Testing: 0 .. 10.. 20..
> FAIL: AddressSanitizer-arm-android :: TestCases/Posix/global-registration.c (112 of 364)
> ******************** TEST 'AddressSanitizer-arm-android :: TestCases/Posix/global-registration.c' FAILED ********************
> Script:
> --
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/android_commands/android_compile.py /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only --target=armv7-linux-androideabi --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm -lm -shared-libasan -c -o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-one.o -DDYNAMICLIB=\"/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-dynamic.so <http://global-registration.c.tmp-dynamic.so/>\" -DMAIN_FILE /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/android_commands/android_compile.py /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only --target=armv7-linux-androideabi --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm -lm -shared-libasan -c -o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-two.o -DSECONDARY_FILE /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/android_commands/android_compile.py /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only --target=armv7-linux-androideabi --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm -lm -shared-libasan -o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-one.o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-two.o
> /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/android_commands/android_compile.py /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm_build64/bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only --target=armv7-linux-androideabi --sysroot=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm/sysroot -B/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/../../../android-ndk/standalone-arm -lm -shared-libasan -shared -fPIC -o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp-dynamic.so <http://global-registration.c.tmp-dynamic.so/> -DSHARED_LIBRARY_FILE /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> not /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp 1 2>&1 | FileCheck --check-prefix ASAN-CHECK-1 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> not /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp 2 2>&1 | FileCheck --check-prefix ASAN-CHECK-2 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> not /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Posix/Output/global-registration.c.tmp 3 2>&1 | FileCheck --check-prefix ASAN-CHECK-3 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
> --
> Exit Code: 2
>
> Command Output (stderr):
> --
> clang-3.9: warning: -lm: 'linker' input unused
> clang-3.9: warning: -lm: 'linker' input unused
> FileCheck error: '-' is empty.
> FileCheck command line: FileCheck --check-prefix ASAN-CHECK-3 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Posix/global-registration.c
>
> --
>
> ********************
> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
> Testing Time: 537.93s
> ********************
> Failing Tests (1):
> AddressSanitizer-arm-android :: TestCases/Posix/global-registration.c
>
> Expected Passes : 165
> Expected Failures : 40
> Unsupported Tests : 158
> Unexpected Failures: 1
> FAILED: cd /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan && /usr/bin/python2.7 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/utils/lit/lit.py -sv /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig
> ninja: build stopped: subcommand failed.
> @@@STEP_FAILURE@@@
> + echo @@@STEP_FAILURE@@@
> + echo @@@BUILD_STEP run sanitizer_common tests '[arm/hammerhead-userdebug/LMY48T]@@@'
>
>
> --------------------------------------------------------------------------------
> started: Thu Jun 23 13:34:17 2016
> ended: Thu Jun 23 15:20:10 2016
> duration: 1 hrs, 45 mins, 53 secs
>
> On Wed, Jun 22, 2016 at 1:06 PM Ryan Govostes via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: rgov
> Date: Wed Jun 22 14:59:10 2016
> New Revision: 273464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273464&view=rev <http://llvm.org/viewvc/llvm-project?rev=273464&view=rev>
> Log:
> [asan] Add a test case for global registration
>
> This test case checks that globals from all object files are being registered
> after they've been linked together. It also checks that globals from libraries
> loaded at runtime are registered.
>
>
> Added:
> compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c
>
> Added: compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c?rev=273464&view=auto <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c?rev=273464&view=auto>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c (added)
> +++ compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c Wed Jun 22 14:59:10 2016
> @@ -0,0 +1,56 @@
> +// Test that globals from different shared objects all get registered.
> +
> +// This source file is compiled into three different source object files. Each
> +// object file declares a global buffer. The first two are linked together, and
> +// the third is loaded at runtime. We make sure that out-of-bounds accesses
> +// are caught for all three buffers.
> +
> +// RUN: %clang_asan -c -o %t-one.o -DDYNAMICLIB=\"%t-dynamic.so\" -DMAIN_FILE %s
> +// RUN: %clang_asan -c -o %t-two.o -DSECONDARY_FILE %s
> +// RUN: %clang_asan -o %t %t-one.o %t-two.o
> +// RUN: %clang_asan -shared -o %t-dynamic.so -DSHARED_LIBRARY_FILE %s
> +// RUN: not %run %t 1 2>&1 | FileCheck --check-prefix ASAN-CHECK-1 %s
> +// RUN: not %run %t 2 2>&1 | FileCheck --check-prefix ASAN-CHECK-2 %s
> +// RUN: not %run %t 3 2>&1 | FileCheck --check-prefix ASAN-CHECK-3 %s
> +
> +#if MAIN_FILE
> +
> +#include <dlfcn.h>
> +#include <stdlib.h>
> +
> +extern char buffer2[1];
> +char buffer1[1] = { };
> +
> +int main(int argc, char *argv[]) {
> + int n = atoi(argv[1]);
> + if (n == 1) {
> + buffer1[argc] = 0;
> + // ASAN-CHECK-1: {{0x.* is located 1 bytes .* 'buffer1'}}
> + } else if (n == 2) {
> + buffer2[argc] = 0;
> + // ASAN-CHECK-2: {{0x.* is located 1 bytes .* 'buffer2'}}
> + } else if (n == 3) {
> + void *handle = dlopen(DYNAMICLIB, RTLD_NOW);
> + if (!handle)
> + return 1;
> +
> + char *buffer = (char *)dlsym(handle, "buffer3");
> + if (!buffer)
> + return 1;
> +
> + buffer[argc] = 0;
> + // ASAN-CHECK-3: {{0x.* is located 1 bytes .* 'buffer3'}}
> + }
> +
> + return 0;
> +}
> +
> +#elif SECONDARY_FILE
> +
> +char buffer2[1] = { };
> +
> +#elif SHARED_LIBRARY_FILE
> +
> +char buffer3[1] = { };
> +
> +#endif
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
> --
> Mike
> Sent from phone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160623/326deccc/attachment.html>
More information about the llvm-commits
mailing list