Skip to content

Commit fe8663b

Browse files
committed
ubsan: refine wording
1 parent 6694b15 commit fe8663b

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

kernel/misc/ubsan.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct type_mismatch_info
3333
struct out_of_bounds_info
3434
{
3535
struct source_location location;
36-
// struct type_descriptor left_type;
37-
// struct type_descriptor right_type;
36+
struct type_descriptor *array_type;
37+
struct type_descriptor *index_type;
3838
};
3939

4040
struct unreachable_data
@@ -50,20 +50,14 @@ static void log_location(struct source_location *location)
5050
void __ubsan_handle_type_mismatch(struct type_mismatch_info *type_mismatch, ptr_t pointer)
5151
{
5252
struct source_location *location = &type_mismatch->location;
53+
pr_emerg();
5354
if (pointer == 0)
54-
{
5555
pr_emerg("NULL pointer access");
56-
}
5756
else if (type_mismatch->alignment != 0 && is_aligned(pointer, type_mismatch->alignment))
58-
{
59-
// Most useful on architectures with stricter memory alignment requirements, like ARM.
60-
pr_emerg("unaligned memory access");
61-
}
57+
pr_emerg("unaligned memory access"); // Most useful on architectures with stricter memory alignment requirements, like ARM.
6258
else
63-
{
6459
pr_emerg("insufficient size");
65-
pr_emerg("kind=%d, address %p with insufficient space for object of type %s", type_mismatch->type_check_kind, (void *) pointer, type_mismatch->type->name);
66-
}
60+
pr_emerg("kind=%d, address %p, for object of type %s", type_mismatch->type_check_kind, (void *) pointer, type_mismatch->type->name);
6761
log_location(location);
6862
}
6963

@@ -105,7 +99,7 @@ void __ubsan_handle_sub_overflow(struct source_location *location, struct type_d
10599
void __ubsan_handle_out_of_bounds(struct out_of_bounds_info *out_of_bounds)
106100
{
107101
struct source_location *location = &out_of_bounds->location;
108-
pr_emerg("out of bounds");
102+
pr_emerg("out of bounds, array type %s, index type %s", out_of_bounds->array_type->name, out_of_bounds->index_type->name);
109103
log_location(location);
110104
}
111105

0 commit comments

Comments
 (0)