ECE 441 · Week 4
Modern Computer: Secure Infrastructure
A rebuild has an identity: the hash of its image, and one console line only that build prints.
Week 4 of 10 · Solitude
ECE 441 · Week 4 · In class
A rebuild has an identity: the hash of its image, and one console line only that build prints.
- A build is reproducible when an independent rebuild from the same source gives the same bytes.
- That is what lets anyone check the binary on a board against its source.
- The toolchain command for a clean rebuild, and the directory it must be run in, are on the bench card the instructor posts for this week.
- Copy both.
ECE 441 · Week 4 · In class
A rebuild has an identity: the hash of its image, and one console line only that build prints. (continued)
- Those two are the homework.
- These notes do not print a second command.
ECE 441 · Week 4 · In class
You and your partner each rebuild from a clean tree on a different bench PC and compare the two image hashes.
- If they differ, find the first bytes that differ and name the cause.
- Boot the board from your build, record the console line the stock image does not print, and write the commands a classmate uses to rebuild and boot it.
- Reboot from the same build and confirm the same identity line.
ECE 441 · Week 4 · Lecture
Why the same bytes matter
- A build is reproducible when an independent rebuild of the same source gives the same bytes.
- Then anyone can check the binary on a board against its source: rebuild, hash, compare.
- If the bytes differ, either the source differs or the build leaks something from the machine.
- Finding and naming that leak is the work, not a failure.
ECE 441 · Week 4 · Lecture
An image's identity
sha256sum <image>
git -C <tree> rev-parse HEAD
git -C <tree> status --porcelain # empty means clean
- The hash names the bytes; the commit names the source they came from.
- A tree with local edits builds a different image from the same commit.
- U-Boot adds
-dirtyto its version when the tree has uncommitted changes.
ECE 441 · Week 4 · Lecture
What leaks into a build
| Leak | How it shows | Usual fix |
|---|---|---|
| Build time | A date string in the image | SOURCE_DATE_EPOCH |
| Build path | Your home directory in the image | Same path, or a prefix map |
| Toolchain | Different code in many places | The same compiler version |
| Local edits | -dirty, or real changes | A clean tree |
ECE 441 · Week 4 · Lecture
Pinning the date
# the time of the last commit, not the time of the build
export SOURCE_DATE_EPOCH=$(git -C TREE log -1 --format=%ct)
date -u -d @"$SOURCE_DATE_EPOCH"
- U-Boot's build uses
SOURCE_DATE_EPOCH, when set, for the date in its banner. - Both partners must set it to the same value, or the date alone makes the images differ.
ECE 441 · Week 4 · Lecture
Finding the first difference
sha256sum mine.bin theirs.bin
cmp mine.bin theirs.bin # first differing byte
cmp -l mine.bin theirs.bin | wc -l # how many differ
strings -t x mine.bin | grep -i '<text>'
cmpgives the offset;strings -t xshows what text sits near it.diffoscope, if installed, explains the difference in one report.
ECE 441 · Week 4 · Lab
Lab
- From a clean tree, rebuild the open bootloader on the bench PC and record the hash of the image; your partner rebuilds it independently on another bench PC.
- Compare the two hashes. If they differ, find the first differing bytes and name the cause, such as a timestamp, a path, or a toolchain version. Boot the board from your build and record the console line that only that build prints. Second pass: reboot from that same build and confirm the same identity line.
ECE 441 · Week 4 · Lab
Lab (continued)
- Assemble the lab hand-in: The two image hashes, identical or with the first difference and its cause, the console line that only your build prints, and the commands a classmate uses to rebuild and boot it.
ECE 441 · Week 4 · Lab
Hand in
The two image hashes, identical or with the first difference and its cause, the console line that only your build prints, and the commands a classmate uses to rebuild and boot it.
ECE 441 · Week 4 · Homework
Homework
- Write the toolchain command the lecture gives for a clean rebuild, and the directory it must be run in.
ECE 441 · Week 4 · Homework
Turn in
The command and the directory.
ECE 441 · Week 4 · Read
Read
On the lab site: Module 4, Loading the bootloader into SRAM, and Module 6, Software in DRAM, describe the stages. This week grades the rebuild. The basic modules stop at Module 12.
ECE 441 · Week 4 · Next
Week 5
A method names instruments, steps, and what to record.