From: Jan Hendrik Farr <kernel@jfarr.cc>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Pingfan Liu <piliu@redhat.com>,
Pingfan Liu <kernelfans@gmail.com>,
linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org,
kexec@lists.infradead.org, Baoquan He <bhe@redhat.com>,
Dave Young <dyoung@redhat.com>, Philipp Rudo <prudo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
keyrings@vger.kernel.org, Luca Boccassi <bluca@debian.org>,
lennart@poettering.net, Jarkko Sakkinen <jarkko@kernel.org>,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org, mjg59@google.com,
James.Bottomley@hansenpartnership.com
Subject: Re: [PATCH 0/2] Sign the Image which is zboot's payload
Date: Thu, 28 Sep 2023 01:46:06 +0200 [thread overview]
Message-ID: <ZRS-vnMyjZRKRLhT@desktop> (raw)
In-Reply-To: <CAMj1kXF0rZ0Ej-+x__E9=Ca8Mesb+N+35etqiUzEMzhRR6trCg@mail.gmail.com>
On 25 08:55:46, Ard Biesheuvel wrote:
> On Mon, 25 Sept 2023 at 03:01, Pingfan Liu <piliu@redhat.com> wrote:
>
> [...]
>
> > > 4. How can we debug the stubs that are being invoked?
> > > 5. Can we let the EFI binary know that this is a kexec and not a normal
> > > bootup. Potentially systemd-stub would want to change how/if it does TPM
> > > PCR measurements.
> > > ...
> > >
> >
>
> Not sure whether this matters. The TPM logic is exposed via EFI
> protocols, and the kernel could either expose them or not. If it does,
> and we execute the EFI stub (sytemd-stub) code all the way through to
> ExitBootServices() while executing in the old kernel, we could even
> take PCR measurements and display them, giving us secure and measured
> boot for kexec.
>
I think we should definitely delay any of the measurements until
ExitBootServices(). We don't wan't measurements of a kernel that is not
running and might even get unloaded before being kexec'ed to make their
way into the TPM.
> > Besides these questions, I wonder whether a highly configured EDK2 can
> > be used as the stub (ArmVirtQemuKernel.dsc can be the start point).
> > But there should be efforts to exclude the drivers which have the MMIO
> > access. I saw Ard is active in EDK2, maybe that is the reason why he
> > did not pick up EDK2 to serve the stub.
> >
>
> I don't think EDK2 is suitable for this - the code style is different,
> the license is different and it is simply a lot of code.
>
> What I would prefer is to define a subset of the EFI boot services
> that we actually rely on, and perhaps even introduce some other
> constraints on the EFI code, e.g., allow it to run unprivileged.
>
> That way, kexec could execute the EFI stub as an ordinary user process
> (to some extent), including allocations for the decompressed kernel,
> initrd, etc. Finally, the only thing purgatory would need to do is
> linearize the populated regions in the VA space and copy them to
> physical memory.
>
> This all sounds very high-level, and there may be some difficulties
> down the road, but I think this deserves a proper look because it is
> an appealing way to make EFI execution idempotent in the context of
> kexec, and also reduces the arch-specific logic substantially.
I just started work on a proof-of-concept implementation of this [1]. It's
kinda unorganized and early right now though. Currently just testing with
executing a bzimage with the normal EFI stub on x86. At this point it starts
executing the EFI stub which checks efi_system_table->hdr.signature for the
correct signature (which I have not set yet). That causes the EFI stub to
exit. It does correctly call the exit function from my provided boot services
table and the correct ExitStatus gets logged in dmesg. So it's able to call
into my boot services correctly.
This is definitly the most low level code I've ever written though, so
I'm just learning this stuff.
Next I'll work on setting up a proper memory mapping for the EFI
application.
After that I'll work on implementing the needed boot services and
protocols.
[1] https://github.com/Cydox/linux/commits/kexec-uefi
--
Jan
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2023-09-27 23:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 13:37 [PATCH 0/2] Sign the Image which is zboot's payload Pingfan Liu
2023-09-21 13:37 ` [PATCH 1/2] zboot: Signing the payload Pingfan Liu
2023-09-21 13:37 ` [PATCH 2/2] arm64: Enable signing on the kernel image loaded by kexec file load Pingfan Liu
2023-09-22 5:19 ` [PATCH 0/2] Sign the Image which is zboot's payload Jan Hendrik Farr
2023-09-22 5:41 ` Dave Young
2023-09-25 15:24 ` Philipp Rudo
2023-09-25 3:01 ` Pingfan Liu
2023-09-25 8:55 ` Ard Biesheuvel
2023-09-27 23:46 ` Jan Hendrik Farr [this message]
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=ZRS-vnMyjZRKRLhT@desktop \
--to=kernel@jfarr.cc \
--cc=James.Bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=bhe@redhat.com \
--cc=bluca@debian.org \
--cc=catalin.marinas@arm.com \
--cc=dyoung@redhat.com \
--cc=jarkko@kernel.org \
--cc=kernelfans@gmail.com \
--cc=kexec@lists.infradead.org \
--cc=keyrings@vger.kernel.org \
--cc=lennart@poettering.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mjg59@google.com \
--cc=piliu@redhat.com \
--cc=prudo@redhat.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).