Skip to content

Commit f18b0d7

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
ubsan: Fix objtool UACCESS warns
clang-14 allyesconfig gives: vmlinux.o: warning: objtool: emulator_cmpxchg_emulated+0x705: call to __ubsan_handle_load_invalid_value() with UACCESS enabled vmlinux.o: warning: objtool: paging64_update_accessed_dirty_bits+0x39e: call to __ubsan_handle_load_invalid_value() with UACCESS enabled vmlinux.o: warning: objtool: paging32_update_accessed_dirty_bits+0x390: call to __ubsan_handle_load_invalid_value() with UACCESS enabled vmlinux.o: warning: objtool: ept_update_accessed_dirty_bits+0x43f: call to __ubsan_handle_load_invalid_value() with UACCESS enabled Add the required eflags save/restore and whitelist the thing. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Tony Lindgren <[email protected]> Tested-by: Ulf Hansson <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ca502fc commit f18b0d7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/ubsan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ void __ubsan_handle_load_invalid_value(void *_data, void *val)
339339
{
340340
struct invalid_value_data *data = _data;
341341
char val_str[VALUE_LENGTH];
342+
unsigned long ua_flags = user_access_save();
342343

343344
if (suppress_report(&data->location))
344-
return;
345+
goto out;
345346

346347
ubsan_prologue(&data->location, "invalid-load");
347348

@@ -351,6 +352,8 @@ void __ubsan_handle_load_invalid_value(void *_data, void *val)
351352
val_str, data->type->type_name);
352353

353354
ubsan_epilogue();
355+
out:
356+
user_access_restore(ua_flags);
354357
}
355358
EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
356359

tools/objtool/check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ static const char *uaccess_safe_builtin[] = {
12161216
"__ubsan_handle_type_mismatch",
12171217
"__ubsan_handle_type_mismatch_v1",
12181218
"__ubsan_handle_shift_out_of_bounds",
1219+
"__ubsan_handle_load_invalid_value",
12191220
/* misc */
12201221
"csum_partial_copy_generic",
12211222
"copy_mc_fragile",

0 commit comments

Comments
 (0)