From 9dd4476c58caf03a36e1483f8c20263210530400 Mon Sep 17 00:00:00 2001 From: Andrey Somsikov Date: Wed, 2 Feb 2022 12:48:21 +0300 Subject: [PATCH] Reduce noise from security tests (#9774) * Mute noicy undefined behavior checks * Fix GCC build error with unsupported option * Fix missprint --- .../compile_flags/sanitizer.cmake | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmake/developer_package/compile_flags/sanitizer.cmake b/cmake/developer_package/compile_flags/sanitizer.cmake index a8e4d19d8f4..e85494aa7e9 100644 --- a/cmake/developer_package/compile_flags/sanitizer.cmake +++ b/cmake/developer_package/compile_flags/sanitizer.cmake @@ -28,9 +28,26 @@ if (ENABLE_UB_SANITIZER) if (WIN32) message(FATAL_ERROR "UndefinedBehavior sanitizer is not supported in Windows") endif() + # TODO: Remove -fno-sanitize=null as thirdparty/ocl/clhpp_headers UBSAN compatibility resolved: # https://github.com/KhronosGroup/OpenCL-CLHPP/issues/17 - set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=null") + # Mute -fsanitize=function Indirect call of a function through a function pointer of the wrong type. + # Sample cases: + # call to function GetAPIVersion through pointer to incorrect function type 'void *(*)()' + # Mute -fsanitize=alignment Use of a misaligned pointer or creation of a misaligned reference. Also sanitizes assume_aligned-like attributes. + # Sample cases: + # VPU_FixedMaxHeapTest.DefaultConstructor test case load of misaligned address 0x62000000187f for type 'const DataType', which requires 4 byte alignment + # Mute -fsanitize=bool Load of a bool value which is neither true nor false. + # Samples cases: + # ie_c_api_version.apiVersion test case load of value 32, which is not a valid value for type 'bool' + # Mute -fsanitize=enum Load of a value of an enumerated type which is not in the range of representable values for that enumerated type. + # Samples cases: + # load of value 4294967295, which is not a valid value for type 'const (anonymous namespace)::onnx::Field' + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=null -fno-sanitize=alignment -fno-sanitize=bool -fno-sanitize=enum") + if(OV_COMPILER_IS_CLANG) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fno-sanitize=function") + endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # TODO: Remove -Wno-maybe-uninitialized after CVS-61143 fix set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -Wno-maybe-uninitialized")