Skip to content

Commit 469cbd0

Browse files
arndbtorvalds
authored andcommitted
lib/ubsan.c: fix gcc-10 warnings
The latest compiler expects slightly different function prototypes for the ubsan helpers: lib/ubsan.c:192:6: error: conflicting types for built-in function '__ubsan_handle_add_overflow'; expected 'void(void *, void *, void *)' [-Werror=builtin-declaration-mismatch] 192 | void __ubsan_handle_add_overflow(struct overflow_data *data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/ubsan.c:200:6: error: conflicting types for built-in function '__ubsan_handle_sub_overflow'; expected 'void(void *, void *, void *)' [-Werror=builtin-declaration-mismatch] 200 | void __ubsan_handle_sub_overflow(struct overflow_data *data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/ubsan.c:207:6: error: conflicting types for built-in function '__ubsan_handle_mul_overflow'; expected 'void(void *, void *, void *)' [-Werror=builtin-declaration-mismatch] 207 | void __ubsan_handle_mul_overflow(struct overflow_data *data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/ubsan.c:214:6: error: conflicting types for built-in function '__ubsan_handle_negate_overflow'; expected 'void(void *, void *)' [-Werror=builtin-declaration-mismatch] 214 | void __ubsan_handle_negate_overflow(struct overflow_data *data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/ubsan.c:234:6: error: conflicting types for built-in function '__ubsan_handle_divrem_overflow'; expected 'void(void *, void *, void *)' [-Werror=builtin-declaration-mismatch] 234 | void __ubsan_handle_divrem_overflow(struct overflow_data *data, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change the Linux implementation to match these, using a local typed pointer. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Kees Cook <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Julien Grall <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2792d48 commit 469cbd0

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/ubsan.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,31 +189,31 @@ static void handle_overflow(struct overflow_data *data, void *lhs,
189189
ubsan_epilogue();
190190
}
191191

192-
void __ubsan_handle_add_overflow(struct overflow_data *data,
192+
void __ubsan_handle_add_overflow(void *data,
193193
void *lhs, void *rhs)
194194
{
195195

196196
handle_overflow(data, lhs, rhs, '+');
197197
}
198198
EXPORT_SYMBOL(__ubsan_handle_add_overflow);
199199

200-
void __ubsan_handle_sub_overflow(struct overflow_data *data,
200+
void __ubsan_handle_sub_overflow(void *data,
201201
void *lhs, void *rhs)
202202
{
203203
handle_overflow(data, lhs, rhs, '-');
204204
}
205205
EXPORT_SYMBOL(__ubsan_handle_sub_overflow);
206206

207-
void __ubsan_handle_mul_overflow(struct overflow_data *data,
207+
void __ubsan_handle_mul_overflow(void *data,
208208
void *lhs, void *rhs)
209209
{
210210
handle_overflow(data, lhs, rhs, '*');
211211
}
212212
EXPORT_SYMBOL(__ubsan_handle_mul_overflow);
213213

214-
void __ubsan_handle_negate_overflow(struct overflow_data *data,
215-
void *old_val)
214+
void __ubsan_handle_negate_overflow(void *_data, void *old_val)
216215
{
216+
struct overflow_data *data = _data;
217217
char old_val_str[VALUE_LENGTH];
218218

219219
if (suppress_report(&data->location))
@@ -231,9 +231,9 @@ void __ubsan_handle_negate_overflow(struct overflow_data *data,
231231
EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
232232

233233

234-
void __ubsan_handle_divrem_overflow(struct overflow_data *data,
235-
void *lhs, void *rhs)
234+
void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
236235
{
236+
struct overflow_data *data = _data;
237237
char rhs_val_str[VALUE_LENGTH];
238238

239239
if (suppress_report(&data->location))
@@ -326,10 +326,9 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
326326
}
327327
EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
328328

329-
void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
330-
void *ptr)
329+
void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
331330
{
332-
331+
struct type_mismatch_data_v1 *data = _data;
333332
struct type_mismatch_data_common common_data = {
334333
.location = &data->location,
335334
.type = data->type,
@@ -341,8 +340,9 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
341340
}
342341
EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
343342

344-
void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index)
343+
void __ubsan_handle_out_of_bounds(void *_data, void *index)
345344
{
345+
struct out_of_bounds_data *data = _data;
346346
char index_str[VALUE_LENGTH];
347347

348348
if (suppress_report(&data->location))
@@ -357,9 +357,9 @@ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index)
357357
}
358358
EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
359359

360-
void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
361-
void *lhs, void *rhs)
360+
void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
362361
{
362+
struct shift_out_of_bounds_data *data = _data;
363363
struct type_descriptor *rhs_type = data->rhs_type;
364364
struct type_descriptor *lhs_type = data->lhs_type;
365365
char rhs_str[VALUE_LENGTH];
@@ -399,18 +399,19 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
399399
EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
400400

401401

402-
void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
402+
void __ubsan_handle_builtin_unreachable(void *_data)
403403
{
404+
struct unreachable_data *data = _data;
404405
ubsan_prologue(&data->location, "unreachable");
405406
pr_err("calling __builtin_unreachable()\n");
406407
ubsan_epilogue();
407408
panic("can't return from __builtin_unreachable()");
408409
}
409410
EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
410411

411-
void __ubsan_handle_load_invalid_value(struct invalid_value_data *data,
412-
void *val)
412+
void __ubsan_handle_load_invalid_value(void *_data, void *val)
413413
{
414+
struct invalid_value_data *data = _data;
414415
char val_str[VALUE_LENGTH];
415416

416417
if (suppress_report(&data->location))

0 commit comments

Comments
 (0)