-
Notifications
You must be signed in to change notification settings - Fork 301
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
Don't make shim abort when TPM log event fails (RHBZ #2002265) #414
Conversation
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.
Looks fine to me.
mok.c
Outdated
return efi_status; | ||
if (EFI_ERROR(tpm_status)) { | ||
dprint(L"tpm_measure_variable(\"%s\",%lu,0x%llx)->%r (ignored)\n", | ||
v->name, FullDataSize, FullData, tpm_status); |
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.
I know the codebase isn't great about this and the problem predates your change, but it would be nice to keep lines <80 characters when it's easy to do so.
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.
In general I agree, but I also really don't like breaking output strings in the middle, as that makes them harder to grep for. So in this case not wrapping is the right thing IMO.
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.
Agreed on the output string, but I'm actually talking about the next line (that supplies the other args to dprint()).
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.
Oh, I see. github's elision of most of the whitespace has fooled me.
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.
I don't really like this approach. Firstly, I think this firmware is really broken. As I said in the private RH bugzilla:
Just reading code and not having any debugging information, this appears that when
"On without Pre-Boot Measurements" is selected, the firmware is registering a protocol
using EFI_TCG_PROTOCOL_GUID that has the expected methods. That protocol provides
a ->StatusCheck() method which returns EFI_SUCCESS and sets the capabilities to
{.TPMPresentFlag = 1, .TPMDeactivatedFlag = 0}. But then, it also provides a
->HashLogExtendEvent() method that returns EFI_UNSUPPORTED?
Is that what's happening? If so, this seems wrong to me. Surely one of the following is
the correct way to implement this:
- set TPMPresentFlag = 0
- set TPMDeactivatedFlag = 1
- don't register the protocol if it's not going to implement anything
But also I'd like a more targeted workaround than ignoring all errors. In this case we're getting EFI_UNSUPPORTED back from calls that should be present, indicating that ->StatusCheck() is lying to us and providing a stubbed out, broken implementation. If that is what's going on, what we should do is add a "tpm_defective" status variable that defaults to false, make tpm_present() always return false if it is set, and make tpm 1.2 calls in tpm.c set it to false if the protocol method they're using gives us EFI_UNSUPPORTED.
On Dell hardware booted in UEFI with option TPM 1.2 "On without Pre-Boot Measurements", it appears that `tpm_log_event()` fails with Unsupported, which causes Shim to abort due to believing it couldn't set up the MokListRT, MokListXRT and SbatLevelRT variables. This patch ignore the error when trying to write to the TPM and sets the TPM as 'defective' to not try to write to it anymore. Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
c4ea6d0
to
355aaa8
Compare
@vathpela Thanks for the review. I updated the code according to your suggestion. |
Log excerpt of the proposed code:
|
On Dell hardware booted in UEFI with option TPM 1.2 "On without Pre-Boot
Measurements", it appears that
tpm_log_event()
fails with Unsupported,which causes Shim to abort due to believing it couldn't set up the
MokListRT, MokListXRT and SbatLevelRT variables.
This patch mimics what is done in Grub code: just ignore failures
related to the TPM.
Below is the verbose output of Shim.