-
-
Notifications
You must be signed in to change notification settings - Fork 199
Improve TPM extend ops output in normal and DEBUG mode #1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5299266
7ca8d42
250a144
de7902f
77d4be1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ fi | |
| # Unify lsmod output to use - instead of _ for comparison | ||
| module_name=$(basename "$MODULE" | sed 's/_/-/g' | sed 's/\.ko$//') | ||
| if lsmod | sed 's/_/-/g' | grep -q "^$module_name\\b"; then | ||
| DEBUG "$MODULE: already loaded" | ||
| DEBUG "$MODULE: already loaded, skipping" | ||
| exit 0 | ||
| fi | ||
|
|
||
|
|
@@ -39,17 +39,14 @@ if [ ! -r /sys/class/tpm/tpm0/pcrs -o ! -x /bin/tpm ]; then | |
| fi | ||
|
|
||
| if [ -z "$tpm_missing" ]; then | ||
| DEBUG "Extending TPM PCR $MODULE_PCR with $MODULE prior of usage" | ||
| echo "TPM: Extending PCR[$MODULE_PCR] with $MODULE prior of loading into kernel" | ||
| tpmr extend -ix "$MODULE_PCR" -if "$MODULE" \ | ||
| || die "$MODULE: tpm extend failed" | ||
| fi | ||
|
|
||
| if [ ! -z "$*" -a -z "$tpm_missing" ]; then | ||
| DEBUG "Extending TPM PCR $MODULE_PCR with $*" | ||
| TMPFILE=/tmp/insmod.$$ | ||
| echo "$@" > $TMPFILE | ||
| DEBUG "Extending TPM PCR $MODULE_PCR with $MODULE prior of usage" | ||
| tpmr extend -ix "$MODULE_PCR" -if $TMPFILE \ | ||
| echo "TPM: Extending PCR[$MODULE_PCR] with $MODULE prior of loading into kernel" | ||
| tpmr extend -ix "$MODULE_PCR" -if "$MODULE" \ | ||
|
||
| || die "$MODULE: tpm extend on arguments failed" | ||
| fi | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to also extend with the CBFS file name. I think we should continue to do that:
tpmr extend -ix "$CONFIG_PCR" -ic "$filename"While it's hard to reason about whether an attack could be possible by moving the entire content of one file to another in some way that doesn't invalidate the PCRs, it's easy to just extend with the file name and be sure there's no such attack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonathonHall-Purism same comment #1758 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonathonHall-Purism We do not to hash the filenames; we want to hash with file content.
Only occurrences in code of TPM PCR exttends
-icops are to extend PCR[4] with hashes of literals:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to hash both. Now it only hashes the content.
This appears to open up an attack by pivoting file contents or renaming files.
For example, say there were only two such files:
echo CONFIG_RESTRICTED_BOOT=y....some GPG key dataAn attacker could manipulate CBFS to the following without affecting the measured PCR state.
echo CONFIG_RESTRICTED_BOOT=y...some GPG key dataHeads would construct the same PCR measurements in this PR because it is only measuring the file content. But the restricted boot config and GPG keyring will be gone, since they've been renamed in such a way that they'll be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(should spell this out 🙂 ) - So my point is you do need to hash both the filename and the content.
It used to do this by putting both the filename and content in a temp file, and hashing that.
A better strategy would be to extend once with the filename, then extend a second time with the file content. (That way the filename and content are clearly separated, you couldn't move the last few letters of the filename to the content, or something like that.)
So include
tpmr extend -ix "$CONFIG_PCR" -ic "$filename"before hashing the file content.