1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2026-01-15 03:10:59 +00:00
serenity/Kernel/FileSystem/SysFS/Subsystems/Kernel/Configuration/KASANDeadly.cpp
Idan Horowitz f7a1f28d7f Kernel: Add initial basic support for KASAN
This commit adds minimal support for compiler-instrumentation based
memory access sanitization.
Currently we only support detection of kmalloc redzone accesses, and
kmalloc use-after-free accesses.

Support for inline checks (for improved performance), and for stack
use-after-return and use-after-return detection is left for future PRs.
2023-12-30 13:57:10 +01:00

31 lines
839 B
C++

/*
* Copyright (c) 2023, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/FileSystem/SysFS/Subsystems/Kernel/Configuration/KASANDeadly.h>
#include <Kernel/Security/AddressSanitizer.h>
namespace Kernel {
UNMAP_AFTER_INIT SysFSKASANDeadly::SysFSKASANDeadly(SysFSDirectory const& parent_directory)
: SysFSSystemBooleanVariable(parent_directory)
{
}
UNMAP_AFTER_INIT NonnullRefPtr<SysFSKASANDeadly> SysFSKASANDeadly::must_create(SysFSDirectory const& parent_directory)
{
return adopt_ref_if_nonnull(new (nothrow) SysFSKASANDeadly(parent_directory)).release_nonnull();
}
bool SysFSKASANDeadly::value() const
{
return AddressSanitizer::g_kasan_is_deadly;
}
void SysFSKASANDeadly::set_value(bool new_value)
{
AddressSanitizer::g_kasan_is_deadly = new_value;
}
}