Skip to content

build: move bootloader data out of measured block#18

Merged
dpsmith merged 4 commits intoTrenchBoot:masterfrom
3mdeb:move_header
Jan 30, 2020
Merged

build: move bootloader data out of measured block#18
dpsmith merged 4 commits intoTrenchBoot:masterfrom
3mdeb:move_header

Conversation

@krystian-hebel
Copy link
Member

Bootloader must fill some information about the kernel (address, size).
Those pieces of information are not constant. To keep hash values
independent of memory layout, those variables are moved to a separate
section out of SL (but still inside SLB). Length in SL header is no
longer set to maximum possible value, it points to the end of constant
data instead.

GRUB2 code must be changed accordingly.

Util for calculating initial PCR values after SKINIT is included
(calc_skinit_lz_sums.sh).

Signed-off-by: Krystian Hebel krystian.hebel@3mdeb.com

    extend_lz_only.sh: print expected values of PCR17 after SKINIT, after
    they are extended with SL hash only (both SHA1 and SHA256).

    extend_all.sh: takes path to bzImage and initrd (in that order) as
    arguments and calculates values expected after extending with LZ,
    kernel and initrd.

    sanity_check.sh: checks for LZ UUID at the correct offset, will be used
    by the following commit.

    util.sh: helper functions for above scripts.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Previous code assumed existence of intermediate loader before the Linux
kernel. As it was not used, code improperly calculated hash from block
of 0 bytes.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Bootloader must pass pointer to the zeropage, which is not constant. To
keep hash values independent of memory layout, those variables are moved
to a separate section out of SL (but still inside SLB). Length in SL
header is no longer set to maximum possible value, it points to the end
of constant data.

GRUB2 code must be changed accordingly.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
#!/bin/bash
. util.sh

if [[ $# -ne 2 ]] || [[ ! -e "$1" ]] || [[ ! -e "$2" ]] ; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! -e is -z

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! -n is -z, -e checks if it is a file. I didn't go with -f because I thought about using symlinks in the build scripts, now I'm not so sure about that.

util.sh Outdated
>&2 echo "\"$TRIM\" is not a valid SHA1/SHA256 hash"
return
fi
echo -n $TRIM | sed -r -e "s/([a-f0-9]{2})/\\\\\x\1/g"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can half the number of escapes for \x given the -r

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do I still need to use 3 backslashes, is the first escape consumed already by quotation?

@andyhhp
Copy link
Collaborator

andyhhp commented Jan 23, 2020

No major problems. Couple of nice-to-haves

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
@krystian-hebel krystian-hebel self-assigned this Jan 28, 2020
@dpsmith dpsmith merged commit c8e39fd into TrenchBoot:master Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants