From: "Hook, Gary" <Gary.Hook@amd.com>
To: "x86@kernel.org" <x86@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"luto@kernel.org" <luto@kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>
Subject: [PATCH 2] x86/mm/mem_encrypt: Disable all instrumentation for SME early files
Date: Mon, 29 Apr 2019 22:22:58 +0000 [thread overview]
Message-ID: <155657657552.7116.18363762932464011367.stgit@sosrh3.amd.com> (raw)
Enablement of AMD's Secure Memory Encryption feature is determined
very early after start_kernel() is entered. Part of this procedure
involves scanning the command line for the parameter 'mem_encrypt'.
To determine intended state, the function sme_enable() uses library
functions cmdline_find_option() and strncmp(). Their use occurs early
enough such that we can't assume that any instrumentation subsystem is
initialized. For example, making calls to a KASAN-instrumented
function before KASAN is set up will result in the use of uninitialized
memory and a boot failure.
When AMD's SME support is enabled, conditionally disable instrumentation
of these dependent functions in lib/string.c and arch/x86/lib/cmdline.c.
Fixes: aca20d546214 ("x86/mm: Add support to make use of Secure Memory Encryption")
Reported-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
arch/x86/lib/Makefile | 16 ++++++++++++++++
lib/Makefile | 14 ++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 140e61843a07..b5b932124280 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -6,6 +6,22 @@
# Produces uninteresting flaky coverage.
KCOV_INSTRUMENT_delay.o := n
+ifdef CONFIG_AMD_MEM_ENCRYPT
+#
+# Early boot use of cmdline; don't instrument it
+#
+KCOV_INSTRUMENT_cmdline.o := n
+
+KASAN_SANITIZE_cmdline.o := n
+
+ifdef CONFIG_FUNCTION_TRACER
+CFLAGS_REMOVE_cmdline.o = -pg
+endif
+
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_cmdline.o := $(nostackp)
+endif
+
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
quiet_cmd_inat_tables = GEN $@
diff --git a/lib/Makefile b/lib/Makefile
index 3b08673e8881..07d71662f6b2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,6 +17,20 @@ KCOV_INSTRUMENT_list_debug.o := n
KCOV_INSTRUMENT_debugobjects.o := n
KCOV_INSTRUMENT_dynamic_debug.o := n
+ifdef CONFIG_AMD_MEM_ENCRYPT
+#
+# Early boot use of cmdline, don't instrument it
+#
+KASAN_SANITIZE_string.o := n
+
+ifdef CONFIG_FUNCTION_TRACER
+CFLAGS_REMOVE_string.o = -pg
+endif
+
+nostackp := $(call cc-option, -fno-stack-protector)
+CFLAGS_string.o := $(nostackp)
+endif
+
lib-y := ctype.o string.o vsprintf.o cmdline.o \
rbtree.o radix-tree.o timerqueue.o xarray.o \
idr.o int_sqrt.o extable.o \
next reply other threads:[~2019-04-29 22:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 22:22 Hook, Gary [this message]
2019-04-30 16:04 ` [tip:x86/urgent] x86/mm/mem_encrypt: Disable all instrumentation for early SME setup tip-bot for Gary Hook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155657657552.7116.18363762932464011367.stgit@sosrh3.amd.com \
--to=gary.hook@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®