From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7E7E211A0B; Tue, 29 Apr 2025 17:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946394; cv=none; b=hXZgxU1pz7kWIhqGBLrHG0v3DFAYCZgb85nwolhLt6SUwDxBi3L0bZVnHu06JolOvcUoyekLEtkHLZ7sDWePHPfA9vGsFimhJbqpaRQ9MHTbt+D8JsT3isQj83uXGySdNMhBeEBjhJ+QNLG5uWhXl7UI6nIEELU1jfO/T75/wjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946394; c=relaxed/simple; bh=4Qt2wBqvlSbZ8lv2j1YHWjMaxg8fMANXQCgBUWdah2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CnPm5ezbJ2U+0GLqqzQcCmCZof95BFRa13+E2XWwRqmyVbnXEO7oi77eAxUqxS+paVFtX2zlYYXMQwlBxxEH4p6z3itwtZ19C4M+mNrHXa51SulaBKgS/lm/KGOfcrbmIaC5hCW1ss4U+6XKaDK85qKSsChugV+o5dUkdeVAudI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=o9Y4RM6D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="o9Y4RM6D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FF9CC4CEE3; Tue, 29 Apr 2025 17:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745946393; bh=4Qt2wBqvlSbZ8lv2j1YHWjMaxg8fMANXQCgBUWdah2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9Y4RM6DoAEibXjYwkkycESnHVchrH5yw+/nvk/Ib36QU1KbrbPlfpwKNsQIr7zY6 QPdB7mnBPRqccBbdxwc7XFhW9dFFz4teo5YFLDpYPHYzLZdEUCRlAvclXt7Ojp5tmE gRZ3C6KjS2VGCKLCquqZTqSgJ4SXMw9hdGVXppUQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Josh Poimboeuf , Ingo Molnar , Kees Cook , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 6.14 222/311] objtool, panic: Disable SMAP in __stack_chk_fail() Date: Tue, 29 Apr 2025 18:40:59 +0200 Message-ID: <20250429161130.113365814@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161121.011111832@linuxfoundation.org> References: <20250429161121.011111832@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josh Poimboeuf [ Upstream commit 72c774aa9d1e16bfd247096935e7dae194d84929 ] __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 Signed-off-by: Ingo Molnar Cc: Kees Cook Cc: Andrew Morton Cc: Linus Torvalds Link: https://lore.kernel.org/r/a3e97e0119e1b04c725a8aa05f7bc83d98e657eb.1742852847.git.jpoimboe@kernel.org Signed-off-by: Sasha Levin --- kernel/panic.c | 6 ++++++ tools/objtool/check.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/panic.c b/kernel/panic.c index d8635d5cecb25..f9f0c5148f6aa 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -832,9 +832,15 @@ device_initcall(register_warn_debugfs); */ __visible noinstr void __stack_chk_fail(void) { + unsigned long flags; + instrumentation_begin(); + flags = user_access_save(); + panic("stack-protector: Kernel stack is corrupted in: %pB", __builtin_return_address(0)); + + user_access_restore(flags); instrumentation_end(); } EXPORT_SYMBOL(__stack_chk_fail); diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 0ca83c74c1f38..bbfd81f49802e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1189,12 +1189,15 @@ static const char *uaccess_safe_builtin[] = { "__ubsan_handle_load_invalid_value", /* STACKLEAK */ "stackleak_track_stack", + /* TRACE_BRANCH_PROFILING */ + "ftrace_likely_update", + /* STACKPROTECTOR */ + "__stack_chk_fail", /* misc */ "csum_partial_copy_generic", "copy_mc_fragile", "copy_mc_fragile_handle_tail", "copy_mc_enhanced_fast_string", - "ftrace_likely_update", /* CONFIG_TRACE_BRANCH_PROFILING */ "rep_stos_alternative", "rep_movs_alternative", "__copy_user_nocache", -- 2.39.5