Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ matrix:
# For C/C++ there is no default install, so we set "install", not "before_install".
install:
- uname -a
- if [[ "`uname`" == "Darwin" ]]; then brew install nasm; fi
# FIXME: remove the "brew update" step once Travis fixes their Mac VM's
# on 11/15/17. Xref https://github.com/travis-ci/travis-ci/issues/8552.
- if [[ "`uname`" == "Darwin" ]]; then brew update; brew install nasm; fi
# ImageMagick is present but these are not:
- if [[ "`uname`" == "Linux" ]]; then sudo apt-get -y install g++-multilib doxygen transfig; fi

Expand Down
2 changes: 1 addition & 1 deletion make/git/hook-pre-commit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my box, /bin/sh -> /bin/dash, and I believe that this script uses a bash-ism. Not sure why I only saw this recently though. Should I change this back?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it bash seems fine: we did the same thing with git_review.sh

#!/bin/bash

# **********************************************************
# Copyright (c) 2014 Google, Inc. All rights reserved.
Expand Down
59 changes: 36 additions & 23 deletions tests/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ set(CMAKE_BUILD_TYPE "Debug")

set_output_dirs("${PROJECT_BINARY_DIR}/tests")

if (UNIX)
set(arch_defs "UNIX")
if (APPLE)
set(arch_defs ${arch_defs} "MACOS")
else (APPLE)
set(arch_defs ${arch_defs} "LINUX")
endif (APPLE)
else (UNIX)
set(arch_defs "WINDOWS")
endif (UNIX)

find_package(DrMemoryFramework PATHS ${framework_dir})

# As we'll be calling configure_DynamoRIO_{client,standalone} from within
Expand All @@ -48,25 +37,19 @@ configure_DynamoRIO_global(OFF ON)

# We save pdb+dll space by not using libc (xref DRi#714).
# For Android, we allow running w/o a private Bionic.
# For Linux x86 we need libc for div+mod routines.
if (WIN32 OR ARM OR ANDROID)
# For Linux x86 we need libc for div+mod routines, as well
# as for Umbra.
if (WIN32 OR ANDROID)
set(DynamoRIO_USE_LIBC OFF)
endif ()

function(add_drmf_test_app app_name src_app)
add_executable(${app_name} ${src_app})
set_property(TARGET ${app_name} PROPERTY COMPILE_DEFINITIONS ${arch_defs})
if (UNIX AND NOT X64 AND NOT ARM)
append_property_string(TARGET ${app_name} COMPILE_FLAGS "-m32")
append_property_string(TARGET ${app_name} LINK_FLAGS "-m32")
endif ()
if (UNIX)
append_property_string(TARGET ${app_name} COMPILE_FLAGS "-g")
else (UNIX)
tobuild(${app_name} ${src_app})
if (WIN32)
# i#1748: disable inlining optimization to avoid calls to
# fuzzing targets being inlined
append_property_string(TARGET ${app_name} COMPILE_FLAGS "/Zi /Ob0")
endif (UNIX)
endif (WIN32)
copy_target_to_device(${app_name})
endfunction(add_drmf_test_app)

Expand Down Expand Up @@ -154,3 +137,33 @@ add_drmf_test(drfuzz_test_no_crash drfuzz_app_segfault drfuzz_client_segfault.c
use_DynamoRIO_extension(drfuzz_test_no_crash.client drsyms)

# XXX i#1734: add multi-threaded test, checking for aborted fuzz targets on all threads

# umbra tests

set(asm_defs "${asm_defs}" -I "${CMAKE_CURRENT_SOURCE_DIR}") # for umbra_test_shared.h
add_drmf_test_app(umbra_app umbra_app.c)
target_include_directories(umbra_app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

add_drmf_test(umbra_test_empty umbra_app umbra_client_empty.c
umbra "" ".*TEST PASSED")

add_drmf_test(umbra_test_shadow_mem umbra_app umbra_client_shadow_mem.c
umbra "" ".*TEST PASSED")
use_DynamoRIO_extension(umbra_test_shadow_mem.client drreg)
use_DynamoRIO_extension(umbra_test_shadow_mem.client drutil)
target_include_directories(umbra_test_shadow_mem.client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR})

add_drmf_test(umbra_test_insert_app_to_shadow umbra_app
umbra_client_insert_app_to_shadow.c umbra "" ".*TEST PASSED")
use_DynamoRIO_extension(umbra_test_insert_app_to_shadow.client drreg)
use_DynamoRIO_extension(umbra_test_insert_app_to_shadow.client drutil)
target_include_directories(umbra_test_insert_app_to_shadow.client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR})

add_drmf_test(umbra_test_consistency umbra_app
umbra_client_consistency.c umbra "" ".*TEST PASSED")
use_DynamoRIO_extension(umbra_test_consistency.client drreg)
use_DynamoRIO_extension(umbra_test_consistency.client drutil)
target_include_directories(umbra_test_consistency.client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR})
167 changes: 167 additions & 0 deletions tests/framework/umbra_app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/* **********************************************************
* Copyright (c) 2017 Google, Inc. All rights reserved.
* **********************************************************/

/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Google, Inc. nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/

#ifndef ASM_CODE_ONLY /* C code ***********************************************/

#include <stdio.h>
#include <stdlib.h>

void asm_test(void);
#ifdef ARM
void asm_test_thumb(void);
#endif

int
main(int argc, char *argv[])
{
asm_test();
#ifdef ARM
asm_test_thumb();
#endif
printf("TEST PASSED\n");
return 0;
}

#else /* asm code *************************************************************/
#include "cpp2asm_defines.h"
#include "umbra_test_shared.h"
START_FILE

#ifdef X64
# define FRAME_PADDING 8
#else
# define FRAME_PADDING 0
#endif

#ifdef ARM
.code 32 /* ARM */
#endif

#define FUNCNAME asm_test
DECLARE_FUNC_SEH(FUNCNAME)
GLOBAL_LABEL(FUNCNAME:)
#ifdef X86
/* push callee-saved registers */
PUSH_SEH(REG_XBX)
PUSH_SEH(REG_XBP)
PUSH_SEH(REG_XSI)
PUSH_SEH(REG_XDI)
sub REG_XSP, FRAME_PADDING /* align */
mov REG_XBP, REG_XSP
sub REG_XSP, 4
END_PROLOG
jmp test1

/* test 1 - write to memory */
test1:
mov REG_XDI, UMBRA_TEST_1_ASM
mov REG_XDI, UMBRA_TEST_1_ASM
mov [REG_XBP], REG_XDI

jmp test2

/* test 2 - read from memory */
test2:
mov REG_XDI, UMBRA_TEST_2_ASM
mov REG_XDI, UMBRA_TEST_2_ASM
mov REG_XDI, [REG_XBP]

jmp epilog

epilog:
mov REG_XSP, REG_XBP
add REG_XSP, FRAME_PADDING /* make a legal SEH64 epilog */
pop REG_XDI
pop REG_XSI
pop REG_XBP
pop REG_XBX
ret
#elif defined(ARM)
push {r4, r7, lr}
sub sp, sp, #4
add r7, sp, #0
b test1

/* test 1 - write to memory */
test1:
movw r4, UMBRA_TEST_1_ASM
movw r4, UMBRA_TEST_1_ASM
str r4, [r7]
b test2

/* test 2 - read from memory */
test2:
movw r4, UMBRA_TEST_2_ASM
movw r4, UMBRA_TEST_2_ASM
ldr r4, [r7]
b epilog

epilog:
add sp, sp, #4
pop {r4, r7, pc}
#endif /* ARM */
END_FUNC(FUNCNAME)
#undef FUNCNAME

#ifdef ARM
.code 16 /* Thumb */
#define FUNCNAME asm_test_thumb
DECLARE_FUNC(FUNCNAME)
GLOBAL_LABEL(FUNCNAME:)
push {r4, r7, lr}
sub sp, sp, #4
add r7, sp, #0
b test3

/* test 1 - write to memory */
test3:
movw r4, UMBRA_TEST_1_ASM
movw r4, UMBRA_TEST_1_ASM
str r4, [r7]
b test4

/* test 2 - read from memory */
test4:
movw r4, UMBRA_TEST_2_ASM
movw r4, UMBRA_TEST_2_ASM
ldr r4, [r7]
b epilog2

epilog2:
add sp, sp, #4
pop {r4, r7, pc}
END_FUNC(FUNCNAME)
#undef FUNCNAME
#endif /* ARM */

END_FILE
#endif
Loading