Skip to content

Commit 72c774a

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool, panic: Disable SMAP in __stack_chk_fail()
__stack_chk_fail() can be called from uaccess-enabled code. Make sure uaccess gets disabled before calling panic(). Fixes the following warning: kernel/trace/trace_branch.o: error: objtool: ftrace_likely_update+0x1ea: call to __stack_chk_fail() with UACCESS enabled Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Kees Cook <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/a3e97e0119e1b04c725a8aa05f7bc83d98e657eb.1742852847.git.jpoimboe@kernel.org
1 parent e63d465 commit 72c774a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

kernel/panic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,15 @@ device_initcall(register_warn_debugfs);
832832
*/
833833
__visible noinstr void __stack_chk_fail(void)
834834
{
835+
unsigned long flags;
836+
835837
instrumentation_begin();
838+
flags = user_access_save();
839+
836840
panic("stack-protector: Kernel stack is corrupted in: %pB",
837841
__builtin_return_address(0));
842+
843+
user_access_restore(flags);
838844
instrumentation_end();
839845
}
840846
EXPORT_SYMBOL(__stack_chk_fail);

tools/objtool/check.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,15 @@ static const char *uaccess_safe_builtin[] = {
11941194
"__ubsan_handle_load_invalid_value",
11951195
/* STACKLEAK */
11961196
"stackleak_track_stack",
1197+
/* TRACE_BRANCH_PROFILING */
1198+
"ftrace_likely_update",
1199+
/* STACKPROTECTOR */
1200+
"__stack_chk_fail",
11971201
/* misc */
11981202
"csum_partial_copy_generic",
11991203
"copy_mc_fragile",
12001204
"copy_mc_fragile_handle_tail",
12011205
"copy_mc_enhanced_fast_string",
1202-
"ftrace_likely_update", /* CONFIG_TRACE_BRANCH_PROFILING */
12031206
"rep_stos_alternative",
12041207
"rep_movs_alternative",
12051208
"__copy_user_nocache",

0 commit comments

Comments
 (0)