From: Dov Murik <dovmurik@linux.ibm.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-efi <linux-efi@vger.kernel.org>,
Gerd Hoffmann <kraxel@redhat.com>, Borislav Petkov <bp@suse.de>,
Ashish Kalra <ashish.kalra@amd.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Andi Kleen <ak@linux.intel.com>,
Greg KH <gregkh@linuxfoundation.org>,
Andrew Scull <ascull@google.com>,
Dave Hansen <dave.hansen@intel.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Lenny Szubowicz <lszubowi@redhat.com>,
Peter Gonda <pgonda@google.com>,
Matthew Garrett <mjg59@srcf.ucam.org>,
James Bottomley <jejb@linux.ibm.com>,
Tobin Feldman-Fitzthum <tobin@linux.ibm.com>,
Jim Cadden <jcadden@ibm.com>,
Daniele Buono <dbuono@linux.vnet.ibm.com>,
linux-coco@lists.linux.dev,
linux-security-module@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Dov Murik <dovmurik@linux.ibm.com>
Subject: Re: [PATCH v8 3/4] efi: Load efi_secret module if EFI secret area is populated
Date: Thu, 31 Mar 2022 12:04:40 +0300 [thread overview]
Message-ID: <38daffb6-a72a-87f4-d927-0b857b7b6833@linux.ibm.com> (raw)
In-Reply-To: <CAMj1kXEKh-Ve3iPDnNTxi10=hcARN4ntpyQOrmb=B+4DpC24vQ@mail.gmail.com>
Hello Ard,
On 28/02/2022 15:15, Ard Biesheuvel wrote:
> On Mon, 28 Feb 2022 at 14:07, Dov Murik <dovmurik@linux.ibm.com> wrote:
>>
>>
>>
>> On 28/02/2022 14:49, Ard Biesheuvel wrote:
>>> On Mon, 28 Feb 2022 at 12:43, Dov Murik <dovmurik@linux.ibm.com> wrote:
>>>>
>>>> If the efi_secret module is built, register a late_initcall in the EFI
>>>> driver which checks whether the EFI secret area is available and
>>>> populated, and then requests to load the efi_secret module.
>>>>
>>>> This will cause the <securityfs>/secrets/coco directory to appear in
>>>> guests into which secrets were injected; in other cases, the module is
>>>> not loaded.
>>>>
>>>> Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
>>>> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
>>>
>>> It would be better to simply expose a platform device and associated
>>> driver, instead of hooking into the module machinery directly.
>>>
>>> We already do something similar for the EFI rtc and the efivars
>>> subsystem, using platform_device_register_simple()
>>>
>>
>> Thanks Ard, I'll look into this.
>>
>> I hope the mechanism you suggest allows me to perform complex check to
>> see if the device is really there (in this case: check for an efi
>> variable, map memory as encrypted, verify it starts with a specific GUID
>> -- everything before request_module() in the code below).
>>
>
> There is the device part and the driver part. Some of this belongs in
> the core code that registers the platform device, and some of it
> belongs in the driver. At this point, it probably does not matter that
> much which side does what, as the platform driver simply probes and
> can perform whatever check it needs, as long as it can back out
> gracefully (although I understand that, in this particular case, there
> are reasons why the driver may decide to wipe the secret)
I finally got to implement this, it seems like it makes the code simple.
Thanks for the advice.
Just making sure I understand correctly: in this approach this we rely
on udev to load the efi_secret module (aliased as "platform:efi_secret")
and call its .probe() function? If there's no udev, the module will not
be loaded automatically. Did I understand that correctly?
In such a case, the only thing needed to add in efi.c is:
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 378d044b2463..b92eabc554e6 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -425,6 +425,9 @@ static int __init efisubsys_init(void)
if (efi_enabled(EFI_DBG) && efi_enabled(EFI_PRESERVE_BS_REGIONS))
efi_debugfs_init();
+ if (efi.coco_secret != EFI_INVALID_TABLE_ADDR)
+ platform_device_register_simple("efi_secret", 0, NULL, 0);
+
return 0;
err_remove_group:
Does this seem OK? (before I re-spin the whole series.)
Thanks,
-Dov
next prev parent reply other threads:[~2022-03-31 9:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 11:42 [PATCH v8 0/4] Allow guest access to EFI confidential computing secret area Dov Murik
2022-02-28 11:42 ` [PATCH v8 1/4] efi: Save location of EFI confidential computing area Dov Murik
2022-02-28 11:42 ` [PATCH v8 2/4] virt: Add efi_secret module to expose confidential computing secrets Dov Murik
2022-03-01 12:24 ` Gerd Hoffmann
2022-02-28 11:42 ` [PATCH v8 3/4] efi: Load efi_secret module if EFI secret area is populated Dov Murik
2022-02-28 12:49 ` Ard Biesheuvel
2022-02-28 13:06 ` Dov Murik
2022-02-28 13:15 ` Ard Biesheuvel
2022-03-31 9:04 ` Dov Murik [this message]
2022-04-12 13:08 ` Ard Biesheuvel
2022-04-12 13:18 ` Dov Murik
2022-02-28 11:42 ` [PATCH v8 4/4] docs: security: Add secrets/coco documentation Dov Murik
2022-03-24 16:33 ` [PATCH v8 0/4] Allow guest access to EFI confidential computing secret area Borislav Petkov
2022-03-29 12:55 ` Dov Murik
2022-03-29 18:30 ` Borislav Petkov
2022-03-29 20:28 ` Dov Murik
2022-03-30 6:11 ` Dov Murik
2022-03-31 9:19 ` Borislav Petkov
2022-03-31 21:05 ` Dov Murik
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=38daffb6-a72a-87f4-d927-0b857b7b6833@linux.ibm.com \
--to=dovmurik@linux.ibm.com \
--cc=ak@linux.intel.com \
--cc=ardb@kernel.org \
--cc=ascull@google.com \
--cc=ashish.kalra@amd.com \
--cc=bp@suse.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@intel.com \
--cc=dbuono@linux.vnet.ibm.com \
--cc=dgilbert@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jcadden@ibm.com \
--cc=jejb@linux.ibm.com \
--cc=jmorris@namei.org \
--cc=kraxel@redhat.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=lszubowi@redhat.com \
--cc=mjg59@srcf.ucam.org \
--cc=pgonda@google.com \
--cc=serge@hallyn.com \
--cc=thomas.lendacky@amd.com \
--cc=tobin@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).