diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index f013ecb1..67b18c5f 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -2648,6 +2648,8 @@ AS_VAR_IF([enable_sanitizers], ["yes"], | |||
2648 | ) | 2648 | ) |
2649 | AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], | 2649 | AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], |
2650 | [ | 2650 | [ |
2651 | AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled]) | ||
2652 | AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT]) | ||
2651 | AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS]) | 2653 | AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS]) |
2652 | enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address" | 2654 | enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address" |
2653 | AC_CACHE_CHECK([whether leak detect is supported], [mhd_cv_cc_sanitizer_address_leak], | 2655 | AC_CACHE_CHECK([whether leak detect is supported], [mhd_cv_cc_sanitizer_address_leak], |
@@ -2691,6 +2693,104 @@ AS_VAR_IF([enable_sanitizers], ["yes"], | |||
2691 | enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract" | 2693 | enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract" |
2692 | ] | 2694 | ] |
2693 | ) | 2695 | ) |
2696 | AS_VAR_IF([ac_cv_header_sanitizer_asan_interface_h],["yes"], | ||
2697 | [ | ||
2698 | AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works], [mhd_cv_func_attribute_nosanitize_ptr], | ||
2699 | [ | ||
2700 | ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" | ||
2701 | export ASAN_OPTIONS | ||
2702 | CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}" | ||
2703 | AC_RUN_IFELSE( | ||
2704 | [ | ||
2705 | AC_LANG_PROGRAM( | ||
2706 | [[ | ||
2707 | #include <stdlib.h> | ||
2708 | |||
2709 | __attribute__((no_sanitize("pointer-compare","pointer-subtract"))) | ||
2710 | int ptr_process(void *ptr1, void *ptr2) | ||
2711 | { | ||
2712 | if ((char*)ptr1 <= (char*)ptr2) | ||
2713 | return (int) ((char*)ptr2 - (char*)ptr1); | ||
2714 | return (int) ((char*)ptr1 - (char*)ptr2); | ||
2715 | } | ||
2716 | ]], | ||
2717 | [[ | ||
2718 | int *a = (int*) malloc (sizeof(int)*4); | ||
2719 | int *b = (int*) malloc (sizeof(long)*6); | ||
2720 | int c = ptr_process(a, b); | ||
2721 | if (c) | ||
2722 | { | ||
2723 | free (b); | ||
2724 | free (a); | ||
2725 | return 0; | ||
2726 | } | ||
2727 | free (a); | ||
2728 | free (b); | ||
2729 | ]] | ||
2730 | ) | ||
2731 | ], | ||
2732 | [mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no], | ||
2733 | [ | ||
2734 | # Cross-compiling with sanitizers?? | ||
2735 | mhd_cv_func_attribute_nosanitize_ptr=no | ||
2736 | ] | ||
2737 | ) | ||
2738 | AS_UNSET([ASAN_OPTIONS]) | ||
2739 | ] | ||
2740 | ) | ||
2741 | AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"], | ||
2742 | [AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WOKRS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works])], | ||
2743 | [ | ||
2744 | AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr], | ||
2745 | [ | ||
2746 | ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" | ||
2747 | export ASAN_OPTIONS | ||
2748 | CFLAGS="${saved_CFLAGS} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS}" | ||
2749 | AC_RUN_IFELSE( | ||
2750 | [ | ||
2751 | AC_LANG_PROGRAM( | ||
2752 | [[ | ||
2753 | #include <stdlib.h> | ||
2754 | |||
2755 | __attribute__((no_sanitize("address"))) | ||
2756 | int ptr_process(void *ptr1, void *ptr2) | ||
2757 | { | ||
2758 | if ((char*)ptr1 <= (char*)ptr2) | ||
2759 | return (int) ((char*)ptr2 - (char*)ptr1); | ||
2760 | return (int) ((char*)ptr1 - (char*)ptr2); | ||
2761 | } | ||
2762 | ]], | ||
2763 | [[ | ||
2764 | int *a = (int*) malloc (sizeof(int)*4); | ||
2765 | int *b = (int*) malloc (sizeof(long)*6); | ||
2766 | int c = ptr_process(a, b); | ||
2767 | if (c) | ||
2768 | { | ||
2769 | free (b); | ||
2770 | free (a); | ||
2771 | return 0; | ||
2772 | } | ||
2773 | free (a); | ||
2774 | free (b); | ||
2775 | ]] | ||
2776 | ) | ||
2777 | ], | ||
2778 | [mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no], | ||
2779 | [ | ||
2780 | # Cross-compiling with sanitizers?? | ||
2781 | mhd_cv_func_attribute_nosanitize_addr=no | ||
2782 | ] | ||
2783 | ) | ||
2784 | AS_UNSET([ASAN_OPTIONS]) | ||
2785 | ] | ||
2786 | ) | ||
2787 | AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"], | ||
2788 | [AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])] | ||
2789 | ) | ||
2790 | ] | ||
2791 | ) | ||
2792 | ] | ||
2793 | ) | ||
2694 | ] | 2794 | ] |
2695 | ) | 2795 | ) |
2696 | dnl Ensure that '#' will be processed correctly | 2796 | dnl Ensure that '#' will be processed correctly |
@@ -2812,6 +2912,15 @@ int main(void) | |||
2812 | ) | 2912 | ) |
2813 | AS_IF([test -z "${enabled_sanitizers}"], | 2913 | AS_IF([test -z "${enabled_sanitizers}"], |
2814 | [AC_MSG_ERROR([cannot find any sanitizer supported by $CC])]) | 2914 | [AC_MSG_ERROR([cannot find any sanitizer supported by $CC])]) |
2915 | AC_MSG_CHECKING([whether to enable user memory poisoning]) | ||
2916 | AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \ | ||
2917 | (test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")], | ||
2918 | [ | ||
2919 | AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used]) | ||
2920 | enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison" | ||
2921 | AC_MSG_RESULT([yes]) | ||
2922 | ], [AC_MSG_RESULT([no])] | ||
2923 | ) | ||
2815 | AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], | 2924 | AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], |
2816 | [ | 2925 | [ |
2817 | AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS]) | 2926 | AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS]) |
@@ -2829,7 +2938,7 @@ int main(void) | |||
2829 | AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1" | 2938 | AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1" |
2830 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64" | 2939 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64" |
2831 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3" | 2940 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3" |
2832 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1" | 2941 | AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:allow_user_poisoning=1:halt_on_error=1" |
2833 | AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"], | 2942 | AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"], |
2834 | [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"]) | 2943 | [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"]) |
2835 | AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1" | 2944 | AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1" |