Skip to content

Commit

Permalink
MDEV-5730 enhance security using special compilation options
Browse files Browse the repository at this point in the history
-Wl,-z,relro,-z,now
-pie
-fstack-protector --param=ssp-buffer-size=4
-D_FORTIFY_SOURCE=2
  • Loading branch information
vuvova committed Jun 26, 2014
1 parent 6c0e3ef commit da4f826
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,20 @@ IF (WITH_ASAN)
ENDIF()
ENDIF()

OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ON)
IF(SECURITY_HARDENED)
# security-enhancing flags
MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")

# sometimes _FORTIFY_SOURCE is predefined
INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(_FORTIFY_SOURCE "" HAVE_FORTIFY_SOURCE)
IF(NOT HAVE_FORTIFY_SOURCE)
ADD_DEFINITIONS(-D_FORTIFY_SOURCE=2)
ENDIF()
ENDIF()

OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON)
IF(ENABLE_DEBUG_SYNC)
Expand Down

0 comments on commit da4f826

Please sign in to comment.