[edk2-devel] measurement to command-line/initrd for loading kernel via -kernel option

Ard Biesheuvel ardb at kernel.org
Sun Sep 18 12:52:16 UTC 2022


Hello Min Xu,

On Sat, 17 Sept 2022 at 04:53, Xu, Min M <min.m.xu at intel.com> wrote:
>
> Hi, Ard
>
> I am checking the measurement behavior when loading the kernel via the QEMU -kernel option. I find it is implemented by below 2 driver/lib:
>
> - OvmfPkg/QemuKernelLoaderFsDxe
>
>  This is a separate DXE driver that exposes the virtual SimpleFileSystem implementation that carries the kernel and initrd passed via the QEMU command line.
>
> - OvmfPkg/Library/X86QemuLoadImageLib
>
>   This is the library that consumes above driver and call LoadImage/StartImage so that the kernel image gets authenticated and/or measured.
>
> See https://edk2.groups.io/g/devel/message/55381
>
>
>
> I have some questions about the implementation need your help.
>
> 1. In the QemuKernelLoaderFsDxe, AllocatePool is called to allocate memory. Why not call AllocatePages? Kernel image size may be around 15 MB, but initrd size maybe much bigger.
>

We use the same code for the command line, which may be much smaller
than a page. On some architectures (AARCH64), page allocations may be
rounded up to 64k multiples.

Note that AllocatePool() will automatically fall back to
AllocatePages() if the allocation is sufficiently large.

> 2. Kernel image is authenticated and/or measured in LoadImage. I am wondering if “command line” is measured as well? “Command line” can be treated as an external input and in my opinion it should be measured too.
>
> 3. The same question to initrd. Is it measured?
>

The initrd is measured by the EFI stub in Linux, and we are currently
adding measurement of the load options to that as well:
https://lore.kernel.org/all/20220916081441.1993492-2-ilias.apalodimas@linaro.org/

The initrd is Linux specific in any case, so there, the Linux OS
loader is a natural place to take care of this. The load options are
being added because of the oversight in the TCG spec, which only
covers load options if they are part of a Boot#### option, but between
LoadImage() and StartImage, you can pass any load options you want via
the loaded image protocol, so it needs to be measured as well.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93919): https://edk2.groups.io/g/devel/message/93919
Mute This Topic: https://groups.io/mt/93737108/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list