-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
tool: drop buggy condition for when to sign #142
Conversation
Hmmm, I'm not exactly sure about this change, @nikstur is the original author who may have the full context in his head. Here's how I read it. (1) If a newer systemd boot is available or systemd-boot is not signed In all the cases, the test failing should probably not fixed by getting rid of condition (2) IMHO, but by fixing the non-idempotency of |
The condition compared the hash of the unsigned input with the signed systemd-boot image/generation image in the "ESP". This means only an identical hash will end up as false, and has likely never happened until removing the signature made the previously signed image identical with the unsigned input. This made lanzaboote not resign it in the test and failing the verify assert.
This was likely caused by I do not see any better way to solve this (input welcome!) as a correct condition would have to check either of these:
Checking these two would not necessarily be faster than just always resigning. |
I see your point. Ugh, this is not ideal. Thanksfully, with the help of @baloo we got into goblin support for computing Authentihashes and reading the certificate table. So theoretically, it should be possible to implement (1) & (2). Give me a bit of time rereading properly again the whole condition logic, I would appreciate if @nikstur could double check this PR as it's not totally my code. Otherwise, I feel like we can just merge it and move forward ideally with a proper implementation later. |
Please don't merge this before I have the time to look over it. I should find some time next week. |
I can change the patch to just comment out the condition with a TODO comment and explanation instead of dropping the other function. This may it easier to review and merge as a stop-gap. I have read through the signing code and I am certain the condition never did what it was meant to in the first place and what was actually checked was not uncovered until the last My question is should the entire check just be dropped as so far it has always signed all existing images. This may be negative for systems with low write endurance e.g. eMMC-based storage, but it also always guaranteed you have signed EFI images from the latest version of the tools involved (including lanzaboote). Hence ensuring determinism in a way. If a proper check is added this guarantee may be hard to continue as the signing tool, lanzaboote version and settings should all be considered inputs to the ideally deterministic signing process and would all need to be checked to not break peoples assumptions when configuring lanzaboote from their nix configurations in my opinion. |
@nikstur What is a good stop-gap solution here? This is breaking people's update process right now. |
Mmh. This PR fails the integration tests when I update dependencies. This may or may not be a better situation than failing to build in the first place. ;) I'll have to look into this in more detail. I should have a solution here in the coming days. Sorry for the long delay. |
Able to post the error? I just updated all the inputs for the flake locally and ran the tool tests again, and everything still passes here. It definitely fixed the issue of lanzaboote not signing images if the unsigned image matches the image in the ESP. |
The tests do succeed if I only update the |
I think this is sensible. @Myaats thank you for the analysis and the fix! I image this was frustrating to track down and has taken quite some time. |
Fixes #140
My theory is that from the last tool update sbattach made removing the image signature from the signed image during the resign test match the initial input. This likely caused the condition at https://github.com/nix-community/lanzaboote/blob/master/rust/tool/src/install.rs#L440 to return false for what I assume is the first time.
I am a bit confused for why this condition exists as it should in theory only return false if the EFI file matches the unsigned input unless I have missed something. The only way to implement that check I can think off is to verify it has been correctly signed, remove the signature table and then compare with the input, at which point it becomes easier to just always sign.