-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add certify example #521
Add certify example #521
Conversation
Okay, I've updated this with many thanks to @ionut-arm for teaching me about how this works. It seems to be working BUT I think this is highlighting a bug in this library. I think we aren't cleaning up sessions properly. This example fails with:
Thing is, if we look at those lines: We clear sessions just before, then we run out of session memory. I have recently been noticing a lot of issues with x0901 errors in the kernel due to session memory, and so I am led to think we have a bug somewhere in how we flush and handle sessions. |
Indeed, you seem to be calling Given that |
You could give the AuthSession an inner Arc that has Drop instead? But yes alternately we need flush_sessions or similar. :) |
The problem with that is the cascade effects to the interface: since you're flushing the session whenever the object gets destoyed, you can't have it implement If you'd like to do this please go ahead! My suggestion was primarily based on expected change size. :) |
Well you can have Clone because you can use Arc/Rc. Probably Rc in this case, because I think these are not really thread safe objects at all.
Well, changing to have an inner that handles things with an Rc is fine, but the question here is do we actually have the apis exposed to flush a session so we can write the drop handler? |
Sorry, I should've been clearer! What I meant about
Of course, here's an example. |
To help explain I'm suggesting we have:
That way the outher AuthSession is still copy/clone, but then when it's dropped we can still auto-flush. |
Ah, I see! Yes, that'll work, though There might be some other issues that I'm not foreseeing, but hopefully implementable if you want to give it a go. |
I think the main issue I'd forsee is the whole API currently still relies on a fair bit of manual memory management anyway. So having some types that auto-free and some that don't could be confusing. Anyway, for now I updated the example with a manual drop of the session and it passes! But eventually if you run these in a loop, duplication, duplication secret and certify all end up leaking memory and causing the TPM RM to lockup. I'm not 100% sure why, I can't find what I'm "not freeing". These are the first examples that use Policy Sessions, so could it by that I need to free those also? |
@ionut-arm Anyway, separate to me fixing session handling, I think a pre-lim review of this would be great then I'll get it sorted for merge by squashing and fixing the commit messages. Is that okay/ |
Yes, apologies for the delay. Staying on top of things has been challenging as of late, will add this to my TODO stack, I'll hopefully get to it today or tomorrow! |
No problem, we all get busy mate. Thank you! |
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.
Thanks for all the work in providing comprehensive examples! I think they're great for anyone who's not dealt with TPMs before!!
Left a number of comments, but overall I'm happy with the flow of the example, quite comprehensive.
One thing to note, though, that your checks aren't fully comprehensive. For example, on the "authority" side you check that the AIK is a TPM key, but don't check that it's restricted. If it's not, that signature verification at the end is useless because the owner of the TPM can call "sign" on any hash they want, including one that mimicks a TPM-resident key certification. Might be worth mentioning that this is a starter example flow.
2f3dc82
to
d99145c
Compare
Updated based on your comments :) |
d99145c
to
cd0e3eb
Compare
Will have another look when I get a bit of time 👀 |
Thank you :) |
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.
Thank you! It looks good to me, though there are a few typos that the spellchecking CI seems to have caught
cd0e3eb
to
0d81eef
Compare
Spellung mistakes fuxed! |
03e9947
to
b660533
Compare
@ionut-arm Need your glowing stamp of approval :) |
I'm good to go, but your commit set seems a bit weird, I wonder if some rebasing happened. Looks like your PR is re-adding two commits from #530 |
I'll rebase and fix it :) |
This adds an example of the use of certify, complete with the make and activate credential processes. Signed-off-by: William Brown <[email protected]>
b660533
to
603f6cd
Compare
@ionut-arm @Superhepper rebased :) |
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 shows how to make an AIK that has been endorsed and is used to certify other objects.