From: Jeremy Linton <jeremy.linton@arm.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Ard Biesheuvel <ardb@kernel.org>
Cc: linux-efi@vger.kernel.org, bp@alien8.de,
sathyanarayanan.kuppuswamy@linux.intel.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] efi/libstub: measure initrd to PCR9 independent of source
Date: Wed, 2 Oct 2024 10:37:21 -0500 [thread overview]
Message-ID: <0bed3801-47c0-439a-8b46-53c2704e9bb0@arm.com> (raw)
In-Reply-To: <CAC_iWjJH8JwdPbL9Et6xNLf4vV1AQDm8ZZh8zYVkb+VFLXedTg@mail.gmail.com>
Hi,
On 10/1/24 2:19 AM, Ilias Apalodimas wrote:
> Thanks, Ard
>
> On Tue, 1 Oct 2024 at 08:59, Ard Biesheuvel <ardb@kernel.org> wrote:
>>
>> (cc Ilias)
>>
>> On Tue, 1 Oct 2024 at 05:20, Jeremy Linton <jeremy.linton@arm.com> wrote:
>>>
>>> Currently the initrd is only measured if it can be loaded using the
>>> INITRD_MEDIA_GUID, if we are loading it from a path provided via the
>>> command line it is never measured. Lets move the check down a couple
>>> lines so the measurement happens independent of the source.
>>>
>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>> ---
>>> drivers/firmware/efi/libstub/efi-stub-helper.c | 9 +++++----
>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
>>> index de659f6a815f..555f84287f0b 100644
>>> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
>>> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
>>> @@ -621,10 +621,6 @@ efi_status_t efi_load_initrd(efi_loaded_image_t *image,
>>> status = efi_load_initrd_dev_path(&initrd, hard_limit);
>>> if (status == EFI_SUCCESS) {
>>> efi_info("Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path\n");
>>> - if (initrd.size > 0 &&
>>> - efi_measure_tagged_event(initrd.base, initrd.size,
>>> - EFISTUB_EVT_INITRD) == EFI_SUCCESS)
>>> - efi_info("Measured initrd data into PCR 9\n");
>>> } else if (status == EFI_NOT_FOUND) {
>>> status = efi_load_initrd_cmdline(image, &initrd, soft_limit,
>>> hard_limit);
>>> @@ -637,6 +633,11 @@ efi_status_t efi_load_initrd(efi_loaded_image_t *image,
>>> if (status != EFI_SUCCESS)
>>> goto failed;
>>>
>>> + if (initrd.size > 0 &&
>>> + efi_measure_tagged_event(initrd.base, initrd.size,
>>> + EFISTUB_EVT_INITRD) == EFI_SUCCESS)
>>> + efi_info("Measured initrd data into PCR 9\n");
>
> Back when we added this we intentionally left loading an initramfs
> loaded via the command line out.
> We wanted people to start using the LoadFile2 protocol instead of the
> command line option, which suffered from various issues -- e.g could
> only be loaded if it resided in the same filesystem as the kernel and
> the bootloader had to reason about the kernel memory layout.
> I don't think measuring the command line option as well is going to
> cause any problems, but isn't it a step backward?
Thanks for looking at this. Since no one else seems to have commented, I
will just express IMHO, that both methods are useful in differing
circumstances.
For a heavyweight Linux aware bootloader like grub/sd-boot the
INITRD_MEDIA_GUID is obviously preferred. But, for booting strictly out
out of a pure UEFI environment or Linux unaware bootloader (ex: UEFI
shell), the commandline based initrd loader is a useful function.
Because, the kernel stub should continue to serve as a complete, if
minimal implementation for booting Linux out of a pure UEFI environment
without additional support infrastructure (shim/grub/etc). So, it seems
that unless there is a reason for divergent behavior it shouldn't exist.
And at the moment, the two primary linux bootloaders grub2 and sdboot
are both using the INITRD_MEDIA_GUID. Given the battering ram has been
successful, it isn't a step backward.
>
> Thanks
> /Ilias
>>> +
>>> status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(initrd),
>>> (void **)&tbl);
>>> if (status != EFI_SUCCESS)
>>> --
>>> 2.46.1
>>>
next prev parent reply other threads:[~2024-10-02 15:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 3:20 Jeremy Linton
2024-10-01 5:58 ` Ard Biesheuvel
2024-10-01 7:19 ` Ilias Apalodimas
2024-10-02 15:37 ` Jeremy Linton [this message]
2024-10-02 16:35 ` Ilias Apalodimas
2024-10-02 16:45 ` Ard Biesheuvel
2024-10-02 17:26 ` Ilias Apalodimas
2024-10-02 17:38 ` Jeremy Linton
2024-10-02 18:24 ` Ilias Apalodimas
2024-10-15 18:23 ` Ard Biesheuvel
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=0bed3801-47c0-439a-8b46-53c2704e9bb0@arm.com \
--to=jeremy.linton@arm.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.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
all inboxes | Powered by JetHome®