mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 09:06:08 +00:00
AK+Kernel+LibSanitizer: Implement __ubsan_handle_function_type_mismatch
This commit is contained in:
parent
7a74805067
commit
1159cd9390
Notes:
sideshowbarker
2024-07-17 07:35:03 +09:00
Author: https://github.com/implicitfield
Commit: 1159cd9390
Pull-request: https://github.com/SerenityOS/serenity/pull/23960
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/DanShaders
Reviewed-by: https://github.com/alimpfard
4 changed files with 37 additions and 0 deletions
|
@ -148,6 +148,11 @@ struct PointerOverflowData {
|
||||||
SourceLocation location;
|
SourceLocation location;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FunctionTypeMismatchData {
|
||||||
|
SourceLocation location;
|
||||||
|
TypeDescriptor const& type;
|
||||||
|
};
|
||||||
|
|
||||||
struct FloatCastOverflowData {
|
struct FloatCastOverflowData {
|
||||||
SourceLocation location;
|
SourceLocation location;
|
||||||
TypeDescriptor const& from_type;
|
TypeDescriptor const& from_type;
|
||||||
|
|
|
@ -141,4 +141,10 @@ void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandl
|
||||||
{
|
{
|
||||||
print_location(data.location);
|
print_location(data.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const&, ValueHandle) __attribute__((used));
|
||||||
|
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const& data, ValueHandle)
|
||||||
|
{
|
||||||
|
print_location(data.location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,4 +208,11 @@ void __ubsan_handle_pointer_overflow(PointerOverflowData const& data, ValueHandl
|
||||||
critical_dmesgln("KUBSAN: addition of unsigned offset to {:p} overflowed to {:p}", base, result);
|
critical_dmesgln("KUBSAN: addition of unsigned offset to {:p} overflowed to {:p}", base, result);
|
||||||
print_location(data.location);
|
print_location(data.location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const&) __attribute__((used));
|
||||||
|
void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData const& data)
|
||||||
|
{
|
||||||
|
critical_dmesgln("KUBSAN: call to function through pointer to incorrect function type {}", data.type.name());
|
||||||
|
print_location(data.location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,4 +482,23 @@ static void handle_float_cast_overflow(FloatCastOverflowData& data, ValueHandle)
|
||||||
handle_float_cast_overflow(data, value);
|
handle_float_cast_overflow(data, value);
|
||||||
ABORT_ALWAYS();
|
ABORT_ALWAYS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_function_type_mismatch(FunctionTypeMismatchData& data, ValueHandle)
|
||||||
|
{
|
||||||
|
auto location = data.location.permanently_clear();
|
||||||
|
if (!location.needs_logging())
|
||||||
|
return;
|
||||||
|
WARNLN_AND_DBGLN("UBSAN: call to function through pointer to incorrect function type {}", data.type.name());
|
||||||
|
print_location(location);
|
||||||
|
}
|
||||||
|
[[gnu::used]] void __ubsan_handle_function_type_mismatch(FunctionTypeMismatchData& data, ValueHandle value)
|
||||||
|
{
|
||||||
|
handle_function_type_mismatch(data, value);
|
||||||
|
ABORT_IF_DEADLY();
|
||||||
|
}
|
||||||
|
[[gnu::used, noreturn]] void __ubsan_handle_function_type_mismatch_abort(FunctionTypeMismatchData& data, ValueHandle value)
|
||||||
|
{
|
||||||
|
handle_function_type_mismatch(data, value);
|
||||||
|
ABORT_ALWAYS();
|
||||||
|
}
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue