[SLOF] [PATCH 0/3] vTPM: Measure the bootloader

Stefan Berger stefanb at linux.ibm.com
Fri Mar 27 12:17:29 AEDT 2020


On 3/26/20 4:20 PM, Stefan Berger wrote:
> This series of patches adds support for measuring the booloader read from
> a GPT partition. Since the boot loader is read into a buffer much bigger
> (0x700000 bytes) than the original file, we need a way to determine the
> original file size of the boot loader, which is assumed to be an ELF file.


To clarify: We need the size of the original file so we know the bytes 
to calculate the sha256 over. This sha256 result must then have the same 
value as if one was to execute for example 'sha256sum grub'. So if grub 
has 82100 bytes in the filesystem we should find the file size of 82100 
by walking the ELF headers -- and then rounding up the size to 4.It does 
do this correctly for grub.


> We do this by extending libelf with a function that allows us to determine
> the ELF file's original file size by walking the ELF headers and looking
> for the farthest offset. In the normal case this will result in the same
> hash calcualted as if one does for example 'sha256sum grub'. However, it
> could lead to a different measurement if the user intentionately appended
> bytes to the file, which are not referenced by any ELF section.
>
> Signed-off-by: Stefan Berger <stefanb at linux.ibm.com>
>
> Stefan Berger (3):
>    elf: Implement elf_get_file_size to determine size of an ELF image
>    tcgbios: Implement tpm_hash_log_extend_event_file
>    tcgbios: Measure the bootloader file read from disk
>
>   include/byteorder.h            | 14 +++++++
>   include/helpers.h              |  2 +
>   include/libelf.h               |  4 ++
>   lib/libelf/elf.c               | 28 +++++++++++++
>   lib/libelf/elf32.c             | 75 ++++++++++++++++++++++++++++++++++
>   lib/libelf/elf64.c             | 63 ++++++++++++++++++++++++++++
>   lib/libtpm/tcgbios.c           | 35 ++++++++++++++++
>   lib/libtpm/tcgbios.h           |  4 ++
>   lib/libtpm/tpm.code            | 19 +++++++++
>   lib/libtpm/tpm.in              |  1 +
>   slof/fs/packages/disk-label.fs | 19 ++++++++-
>   11 files changed, 263 insertions(+), 1 deletion(-)
>



More information about the SLOF mailing list