1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

Kernel: Expose sysctl 'ubsan_is_deadly' to panic the Kernel on UB

This makes it easier to find UB, for example when fuzzing the Kernel.

This can be enabled by default, thanks to @boricj's work in
32e1354b9b.
This commit is contained in:
Ben Wiederhake 2021-03-04 22:07:23 +01:00 committed by Andreas Kling
parent a0362d827c
commit 00131d244e
3 changed files with 14 additions and 1 deletions

View file

@ -26,22 +26,26 @@
#include <AK/Format.h>
#include <Kernel/KSyms.h>
#include <Kernel/Panic.h>
#include <Kernel/UBSanitizer.h>
using namespace Kernel;
using namespace Kernel::UBSanitizer;
bool Kernel::UBSanitizer::g_ubsan_is_deadly { true };
extern "C" {
static void print_location(const SourceLocation& location)
{
if (!location.filename()) {
dbgln("KUBSAN: in unknown file");
} else {
dbgln("KUBSAN: at {}, line {}, column: {}", location.filename(), location.line(), location.column());
}
dump_backtrace();
if (g_ubsan_is_deadly)
PANIC("UB is configured to be deadly.");
}
void __ubsan_handle_load_invalid_value(const InvalidValueData&, ValueHandle);