Skip to content

Commit 26f15e5

Browse files
arndbkees
authored andcommitted
ubsan: add prototypes for internal functions
Most of the functions in ubsan that are only called from generated code don't have a prototype, which W=1 builds warn about: lib/ubsan.c:226:6: error: no previous prototype for '__ubsan_handle_divrem_overflow' [-Werror=missing-prototypes] lib/ubsan.c:307:6: error: no previous prototype for '__ubsan_handle_type_mismatch' [-Werror=missing-prototypes] lib/ubsan.c:321:6: error: no previous prototype for '__ubsan_handle_type_mismatch_v1' [-Werror=missing-prototypes] lib/ubsan.c:335:6: error: no previous prototype for '__ubsan_handle_out_of_bounds' [-Werror=missing-prototypes] lib/ubsan.c:352:6: error: no previous prototype for '__ubsan_handle_shift_out_of_bounds' [-Werror=missing-prototypes] lib/ubsan.c:394:6: error: no previous prototype for '__ubsan_handle_builtin_unreachable' [-Werror=missing-prototypes] lib/ubsan.c:404:6: error: no previous prototype for '__ubsan_handle_load_invalid_value' [-Werror=missing-prototypes] Add prototypes for all of these to lib/ubsan.h, and remove the one that was already present in ubsan.c. Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Fangrui Song <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d0f9084 commit 26f15e5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/ubsan.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,6 @@ void __ubsan_handle_load_invalid_value(void *_data, void *val)
423423
}
424424
EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
425425

426-
void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
427-
unsigned long align,
428-
unsigned long offset);
429426
void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
430427
unsigned long align,
431428
unsigned long offset)

lib/ubsan.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,15 @@ typedef s64 s_max;
124124
typedef u64 u_max;
125125
#endif
126126

127+
void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs);
128+
void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, void *ptr);
129+
void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr);
130+
void __ubsan_handle_out_of_bounds(void *_data, void *index);
131+
void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs);
132+
void __ubsan_handle_builtin_unreachable(void *_data);
133+
void __ubsan_handle_load_invalid_value(void *_data, void *val);
134+
void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
135+
unsigned long align,
136+
unsigned long offset);
137+
127138
#endif

0 commit comments

Comments
 (0)