Turn ON NA_USE_SM by default and warn user about yama settings
@@ -125,13 +125,24 @@ if(NA_USE_CCI)
endif()
# SM
-option(NA_USE_SM "Use shared-memory plugin." OFF)
+option(NA_USE_SM "Use shared-memory plugin." ON)
if(NA_USE_SM)
if(WIN32)
- message(FATAL_ERROR "SM plugin not supported on this platform yet.")
+ message(WARNING "SM plugin not supported on this platform yet.")
else()
include(CheckFunctionExists)
check_function_exists(process_vm_readv NA_SM_HAS_CMA)
+ if(NA_SM_HAS_CMA)
+ execute_process(COMMAND /usr/sbin/sysctl -n kernel.yama.ptrace_scope
+ OUTPUT_VARIABLE NA_SM_YAMA_LEVEL ERROR_VARIABLE NA_SM_YAMA_SYSCTL_ERROR)
+ if(NOT NA_SM_YAMA_SYSCTL_ERROR) # Yama is present
+ if(NA_SM_YAMA_LEVEL EQUAL 1)
+ message(WARNING "Kernel Yama configuration only allows NA SM restricted cross-memory attach, please refer to the mercury documentation for more details.")
+ elseif(NA_SM_YAMA_LEVEL GREATER 1)
+ message(FATAL_ERROR "Kernel Yama configuration does not allow NA SM cross-memory attach, for more details please refer to: https://www.kernel.org/doc/Documentation/security/Yama.txt.")
+ endif()
+ endif()
+ endif()
if(NA_SM_HAS_CMA OR APPLE)
set(NA_PLUGINS ${NA_PLUGINS} na)
set(NA_HAS_SM 1)
@@ -142,7 +153,7 @@ if(NA_USE_SM)
mark_as_advanced(NA_SM_SHM_PREFIX)
mark_as_advanced(NA_SM_TMP_DIRECTORY)
else()
- message(FATAL_ERROR "Platform does not meet NA SM requirements.")
+ message(WARNING "Platform does not meet NA SM requirements.")
endif()
endif()
endif()
