more UBsan
This commit is contained in:
@@ -158,3 +158,136 @@ void __ubsan_handle_out_of_bounds(void* data_raw, void* index_raw)
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: out of bounds");
|
||||
}
|
||||
|
||||
/*
|
||||
* __ubsan_handle_divrem_overflow - Hook for UBSan
|
||||
* @data_raw: pointer to error data
|
||||
* @lhs_raw: left hand side operator
|
||||
* @rhs_raw: right hand side operator
|
||||
*
|
||||
* This function is executed when the UBSan library detects
|
||||
* following undefined behavior: division remainder overflow.
|
||||
* It halts the system and gives the location of the code
|
||||
* that triggered it.
|
||||
*/
|
||||
void __ubsan_handle_divrem_overflow(void* data_raw, void* lhs_raw, void* rhs_raw)
|
||||
{
|
||||
struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw;
|
||||
uintptr_t lhs = (uintptr_t) lhs_raw;
|
||||
uintptr_t rhs = (uintptr_t) rhs_raw;
|
||||
struct ubsan_source_location* loc = &data->location;
|
||||
|
||||
DEBUG("\x1b[38;5;231mUBSan: division remainder overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
|
||||
if (init.all) {
|
||||
printf("\x1b[38;5;231mUBSan: division remainder overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
}
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: division remainder overflow");
|
||||
}
|
||||
|
||||
/*
|
||||
* __ubsan_handle_sub_overflow - Hook for UBSan
|
||||
* @data_raw: pointer to error data
|
||||
* @lhs_raw: left hand side operator
|
||||
* @rhs_raw: right hand side operator
|
||||
*
|
||||
* This function is executed when the UBSan library detects
|
||||
* following undefined behavior: subtraction overflow.
|
||||
* It halts the system and gives the location of the code
|
||||
* that triggered it.
|
||||
*/
|
||||
void __ubsan_handle_sub_overflow(void* data_raw, void* lhs_raw, void* rhs_raw)
|
||||
{
|
||||
struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw;
|
||||
uintptr_t lhs = (uintptr_t) lhs_raw;
|
||||
uintptr_t rhs = (uintptr_t) rhs_raw;
|
||||
struct ubsan_source_location* loc = &data->location;
|
||||
|
||||
DEBUG("\x1b[38;5;231mUBSan: subtraction overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
|
||||
if (init.all) {
|
||||
printf("\x1b[38;5;231mUBSan: subtraction overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
}
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: subtraction overflow");
|
||||
}
|
||||
|
||||
/*
|
||||
* __ubsan_handle_add_overflow - Hook for UBSan
|
||||
* @data_raw: pointer to error data
|
||||
* @lhs_raw: left hand side operator
|
||||
* @rhs_raw: right hand side operator
|
||||
*
|
||||
* This function is executed when the UBSan library detects
|
||||
* following undefined behavior: addition overflow.
|
||||
* It halts the system and gives the location of the code
|
||||
* that triggered it.
|
||||
*/
|
||||
void __ubsan_handle_add_overflow(void* data_raw, void* lhs_raw, void* rhs_raw)
|
||||
{
|
||||
struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw;
|
||||
uintptr_t lhs = (uintptr_t) lhs_raw;
|
||||
uintptr_t rhs = (uintptr_t) rhs_raw;
|
||||
struct ubsan_source_location* loc = &data->location;
|
||||
|
||||
DEBUG("\x1b[38;5;231mUBSan: addition overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
|
||||
if (init.all) {
|
||||
printf("\x1b[38;5;231mUBSan: addition overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
}
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: addition overflow");
|
||||
}
|
||||
|
||||
/*
|
||||
* __ubsan_handle_mul_overflow - Hook for UBSan
|
||||
* @data_raw: pointer to error data
|
||||
* @lhs_raw: left hand side operator
|
||||
* @rhs_raw: right hand side operator
|
||||
*
|
||||
* This function is executed when the UBSan library detects
|
||||
* following undefined behavior: multiplication overflow.
|
||||
* It halts the system and gives the location of the code
|
||||
* that triggered it.
|
||||
*/
|
||||
void __ubsan_handle_mul_overflow(void* data_raw, void* lhs_raw, void* rhs_raw)
|
||||
{
|
||||
struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw;
|
||||
uintptr_t lhs = (uintptr_t) lhs_raw;
|
||||
uintptr_t rhs = (uintptr_t) rhs_raw;
|
||||
struct ubsan_source_location* loc = &data->location;
|
||||
|
||||
DEBUG("\x1b[38;5;231mUBSan: multiplication overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
|
||||
if (init.all) {
|
||||
printf("\x1b[38;5;231mUBSan: multiplication overflow (lhs=%p, rhs=%p) at %s:%u:%u\x1b[0m", lhs, rhs, loc->filename, loc->line, loc->column);
|
||||
}
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: multiplication overflow");
|
||||
}
|
||||
|
||||
/*
|
||||
* __ubsan_handle_negate_overflow - Hook for UBSan
|
||||
* @data_raw: pointer to error data
|
||||
* @old_value_raw: value before overflow
|
||||
*
|
||||
* This function is executed when the UBSan library detects
|
||||
* following undefined behavior: negation overflow.
|
||||
* It halts the system and gives the location of the code
|
||||
* that triggered it.
|
||||
*/
|
||||
void __ubsan_handle_negate_overflow(void* data_raw, void* old_value_raw)
|
||||
{
|
||||
struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw;
|
||||
uintptr_t old_value = (uintptr_t) old_value_raw;
|
||||
struct ubsan_source_location* loc = &data->location;
|
||||
|
||||
DEBUG("\x1b[38;5;231mUBSan: negation overflow (old_value=%p) at %s:%u:%u\x1b[0m", old_value, loc->filename, loc->line, loc->column);
|
||||
|
||||
if (init.all) {
|
||||
printf("\x1b[38;5;231mUBSan: negation overflow (old_value=%p) at %s:%u:%u\x1b[0m", old_value, loc->filename, loc->line, loc->column);
|
||||
}
|
||||
|
||||
panic(NULL, "Undefined Behavior Sanitization error: negation overflow");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user