ImageDecoder: Disable LSan in the sandboxed helper

Keep the ImageDecoder sandbox available in sanitizer builds, but opt the
helper out of LeakSanitizer process-exit leak scans. LSan inspects
procfs during that scan, which conflicts with the helper filesystem
sandbox.

Skip the glibc malloc arena tweak under ASan as well, since ASan's
allocator makes mallopt(M_ARENA_MAX) fail and does not need that glibc
runtime workaround.
This commit is contained in:
Andreas Kling 2026-05-20 20:15:13 +02:00 committed by Andreas Kling
parent 7ecba1c6dc
commit e83836b928
3 changed files with 23 additions and 1 deletions

View file

@ -21,6 +21,9 @@ add_executable(ImageDecoder main.cpp)
if (LINUX)
target_sources(ImageDecoder PRIVATE SandboxLinux.cpp)
if (ENABLE_ADDRESS_SANITIZER)
target_sources(ImageDecoder PRIVATE LeakSanitizer.cpp)
endif()
else()
target_sources(ImageDecoder PRIVATE SandboxUnimplemented.cpp)
endif()

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Platform.h>
#if defined(HAS_ADDRESS_SANITIZER) && defined(AK_OS_LINUX)
extern "C" {
int __lsan_is_turned_off();
[[gnu::used]] int __lsan_is_turned_off()
{
return 1;
}
}
#endif

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Platform.h>
#include <AK/ScopeGuard.h>
#include <ImageDecoder/Sandbox.h>
#include <errno.h>
@ -293,7 +294,7 @@ ErrorOr<void> install_no_new_privileges()
ErrorOr<void> configure_runtime_for_sandbox()
{
#if defined(__GLIBC__) && defined(M_ARENA_MAX)
#if defined(__GLIBC__) && defined(M_ARENA_MAX) && !defined(HAS_ADDRESS_SANITIZER)
if (mallopt(M_ARENA_MAX, 4) == 0)
return Error::from_string_literal("mallopt(M_ARENA_MAX) failed");
#endif