1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:57:36 +00:00

Userland: Port UBSAN implementation to userspace

Take Kernel/UBSanitizer.cpp and make a copy in LibSanitizer.

We can use LibSanitizer to hold other sanitizers as people implement
them :^).

To enable UBSAN for LibC, DynamicLoader, and other low level system
libraries, LibUBSanitizer is built as a serenity_libc, and has a static
version for LibCStatic to use. The approach is the same as that taken in

Note that this means now UBSAN is enabled for code generators, Lagom,
Kernel, and Userspace with -DENABLE_UNDEFINED_SANTIZER=ON. In userspace
however, UBSAN is not deadly (yet).

Co-authored-by: ForLoveOfCats <ForLoveOfCats@vivaldi.net>
This commit is contained in:
Andrew Kaster 2021-05-23 19:40:22 -06:00 committed by Andreas Kling
parent 505f84daae
commit 4a5a1e8648
6 changed files with 259 additions and 2 deletions

View file

@ -110,6 +110,11 @@ include_directories(.)
include_directories(${CMAKE_BINARY_DIR})
add_subdirectory(Meta/Lagom)
if (ENABLE_UNDEFINED_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
add_subdirectory(Userland/DevTools/IPCCompiler)
add_subdirectory(Userland/DevTools/StateMachineGenerator)
add_subdirectory(Userland/Libraries/LibWeb/CodeGenerators)
@ -233,6 +238,15 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Services)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland)
# FIXME: vptr sanitizing requires.. intense ABI wrangling of std::type_info
# And would be better served by porting ubsan_type_hash_itanium.cpp from compiler-rt
# We don't set this along with the original fsanitize=undefined because for host tools, we can rely on
# the host's libubsan to provide the ABI-specific vptr type cache.
# This is not a problem for the Kernel, because it does not have RTTI enabled :^)
if (ENABLE_UNDEFINED_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=vptr")
endif()
add_subdirectory(AK)
add_subdirectory(Kernel)
add_subdirectory(Userland)