-
Notifications
You must be signed in to change notification settings - Fork 98
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
Increase underhill_attestation
lib
unit test coverage
#635
base: main
Are you sure you want to change the base?
Increase underhill_attestation
lib
unit test coverage
#635
Conversation
…ev dependencies for testing
persist_all_key_protectors
@@ -1042,7 +1042,7 @@ async fn persist_all_key_protectors( | |||
.dek_buffer | |||
.fill(0); | |||
key_protector.gsp[key_protector.active_kp as usize % NUMBER_KP].gsp_length = 0; | |||
key_protector.active_kp += 1; | |||
key_protector.active_kp += 1; // TODO: This is vulnerable to overflows |
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.
is there an issue tracking this? what would the mitigation be?
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 have a dev branch where I'm working on a fix. I can create an issue and reference it in my eventual PR
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.
Yeah, that'd be great 👍
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.
We only do modulo 2 against the value so the overflow should be safe, but it's great to improve the code that was ported from C/C++
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.
Afaik arithmetic overflow will lead to a panic in Rust (unless that can/is disabled somehow in OpenVMM/OpenHCL) so this could lead to an OpenHCL crash. I demonstrated this with a should_panic
test in this PR.
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, in that case can we do wrapped add here instead of having the test?
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.
Actually panic
ing due to arithmetic overflow doesn't look like the default behavior when building with release
. So in the wild this would just overflow to 0. I think it could still be worth looking at making this a little nicer.
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.
After checking my understanding that the overflow won't panic when built in release
, I'm less inclined to create an issue for this @daprilik. As Ming-wei mentioned, the usage of active_kp
doesn't care if the value has overflowed to 0 so this logic should be fine. I can take the overflow test out since it doesn't demonstrate release
behavior.
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.
If overflow is explicitly expected and allowed, this code should switch over to using wrapping_add
, and there should be a comment pointing out why wrapping around isn't an issue.
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.
Documented this in #640 and suggested a couple improvements
This PR:
underhill_attestation
crate'slib
lib
that don't expect aGuestEmulationTransportClient
parameter (any guidance on how to construct this in a test would be appreciated)