From: Gary R Hook <ghook@amd.com>
To: Thomas Gleixner <tglx@linutronix.de>, "Hook, Gary" <Gary.Hook@amd.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"x86@kernel.org" <x86@kernel.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"luto@kernel.org" <luto@kernel.org>,
Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH] x86/mm/mem_encrypt: Disable all instrumentation for SME early boot code
Date: Mon, 8 Apr 2019 16:46:31 +0000 [thread overview]
Message-ID: <5dfcb133-0a0e-9e07-3774-313e30814e79@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1904042237020.1802@nanos.tec.linutronix.de>
On 4/4/19 3:42 PM, Thomas Gleixner wrote:
> On Thu, 4 Apr 2019, Hook, Gary wrote:
>
>> Enablement of AMD's Secure Memory Encryption feature is determined
>> very early in the boot cycle. Part of this procedure involves scanning
>> the command line for the paramater '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 likely result in the use of
>> uninitialized memory and a boot failure.
>>
>> Avoid instrumenting these dependent functions by:
>>
>> 1) Making a local, static, renamed copy of strncpy() for use solely in
>> mem_encrypt_identity.c. In this file we are able to vet its few uses
>> and avoid exposing the rest of the kernel to a ubiquitously used but
>> un-instrumented function.
>>
>> 2) Disable instrumention of arch/x86/lib/cmdline.c based on the
>> assumption that the needed function (cmdline_find_option()) is vetted
>> through its use to date, and contains no lurking flaws that have not
>> yet been found through instrumentation such as KASAN.
>
> Not happy about that :)
My reasoning (not arguing): the file has been touched exactly one time
in 4 years, by Thomas. Doesn't appear to be a candidate for constant
modification, so this approach doesn't seem risky to me. I could be wrong.
>> +# SME early boot code checks the cmdline, so don't instrument
>> +KCOV_INSTRUMENT_cmdline.o := n
>> +
>> +KASAN_SANITIZE_cmdline.o := n
>
> If we can't come up with a better solution then this needs to depend on
> CONFIG_MEM_ENCRYPT so we still can run KASAN on cmdline.c to catch crap
> when the code is modified in the future.
We have considered this problem, and see no alternative solution. But I
would love to come up with one.
In the meantime, I've already created a v2 patch that fulfills your
request. I'll wait a few more days for comments before posting.
next prev parent reply other threads:[~2019-04-08 16:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 20:26 Hook, Gary
2019-04-04 20:42 ` Thomas Gleixner
2019-04-08 16:46 ` Gary R Hook [this message]
2019-04-08 16:58 ` Borislav Petkov
2019-04-08 18:41 ` Gary R Hook
2019-04-08 19:08 ` Borislav Petkov
2019-04-09 13:47 ` Lendacky, Thomas
2019-04-26 15:11 ` Gary R Hook
2019-04-26 16:24 ` Borislav Petkov
2019-04-29 20:16 ` Gary R Hook
2019-04-29 20:51 ` Borislav Petkov
2019-04-29 21:22 ` Gary R 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=5dfcb133-0a0e-9e07-3774-313e30814e79@amd.com \
--to=ghook@amd.com \
--cc=Gary.Hook@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=glider@google.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®