[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ac5de854-d274-92ab-a0fa-9a0e738a68fa@intel.com>
Date: Mon, 8 May 2023 13:15:59 -0700
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: "Elliott, Robert (Servers)" <elliott@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"dm-devel@...hat.com" <dm-devel@...hat.com>
CC: "ebiggers@...nel.org" <ebiggers@...nel.org>,
"gmazyland@...il.com" <gmazyland@...il.com>,
"Lutomirski, Andy" <luto@...nel.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"bp@...e.de" <bp@...e.de>, "mingo@...nel.org" <mingo@...nel.org>,
"x86@...nel.org" <x86@...nel.org>,
"herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
"ardb@...nel.org" <ardb@...nel.org>,
"Williams, Dan J" <dan.j.williams@...el.com>,
"Keany, Bernie" <bernie.keany@...el.com>,
"Gairuboyina, Charishma1" <charishma1.gairuboyina@...el.com>,
"Krishnakumar, Lalithambika" <lalithambika.krishnakumar@...el.com>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v6 07/12] x86/cpu/keylocker: Load an internal wrapping key
at boot-time
On 5/8/2023 12:18 PM, Elliott, Robert (Servers) wrote:
>
>> diff --git a/arch/x86/kernel/keylocker.c b/arch/x86/kernel/keylocker.c
> ...
>> +void __init destroy_keylocker_data(void)
>> +{
>> + memset(&kl_setup.key, KEY_DESTROY, sizeof(kl_setup.key));
>> +}
>
> That's a special value for garbage collected keyring keys assigned
> a keytype of ".dead". memzero() or memzero_explicit() might be better
> for this use case.
memzero() looks to be the same as memset() in x86:
$ git grep memzero arch/x86/ | grep define
arch/x86/boot/compressed/misc.c:#define memzero(s, n) memset((s), 0, (n))
Instead, memzero_explicit() looks to be about the right call here:
/**
* memzero_explicit - Fill a region of memory (e.g. sensitive
* keying data) with 0s.
...
* Note: usually using memset() is just fine (!), but in cases
* where clearing out _local_ data at the end of a scope is
* necessary, memzero_explicit() should be used instead in
* order to prevent the compiler from optimising away zeroing.
...
Then,
void __init destroy_keylocker_data(void)
{
memzero_explicit(&kl_setup.key, sizeof(kl_setup.key));
}
Thanks,
Chang
Powered by blists - more mailing lists