Skip to content
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

tpm2-setup: Don't fail if we can't access the TPM due to authorization failure #32899

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DaanDeMeyer
Copy link
Contributor

@DaanDeMeyer DaanDeMeyer commented May 17, 2024

The TPM might be password/pin protected for various reasons even if
there is no SRK yet. Let's handle those cases gracefully instead of
failing the unit as it is enabled by default.

@github-actions github-actions bot added util-lib units tpm2 please-review PR is ready for (re-)review by a maintainer labels May 17, 2024
Copy link

Important

An -rc1 tag has been created and a release is being prepared, so please note that PRs introducing new features and APIs will be held back until the new version has been released.

@yuwata
Copy link
Member

yuwata commented May 17, 2024

Is this for #32898?

src/shared/tpm2-util.c Outdated Show resolved Hide resolved
src/tpm2-setup/tpm2-setup.c Outdated Show resolved Hide resolved
src/tpm2-setup/tpm2-setup.c Outdated Show resolved Hide resolved
@poettering
Copy link
Member

Can we please add a structured log message with message id/catalog entry for this?

@YHNdnzj YHNdnzj added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels May 17, 2024
@github-actions github-actions bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels May 30, 2024
@poettering
Copy link
Member

I'd like to understand better what kind of "lock" you ran into. The error check you are doing here suggests to me that you might have a PIN (aka "authValue") set on the "owner" hierarchy of your TPM? Which is different from "dictionary attack lockout" (aka "DA lockout") which I assumed this was about.

So what is it actually about here? How did you run into this? And do you have debug logs of how tpm2-setup fails on that system?

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented May 30, 2024

I'd like to understand better what kind of "lock" you ran into. The error check you are doing here suggests to me that you might have a PIN (aka "authValue") set on the "owner" hierarchy of your TPM? Which is different from "dictionary attack lockout" (aka "DA lockout") which I assumed this was about.

So what is it actually about here? How did you run into this? And do you have debug logs of how tpm2-setup fails on that system?

I don't have debug logs anymore, but the gist of it is that the unit fails with TPM2_RC_BAD_AUTH in tpm2_create_primary(). My cursory googling seemed to indicate this means the TPM is locked, but I guess I was wrong. I'm happy to update the error messages to say that there's a pin on the owner hierarchy. Either way, we should gracefully handle this.

@poettering
Copy link
Member

TPM is locked, but I guess I was wrong.

Well, "TPM locked" is a bit vague. Could mean "in DA lockout", or could be "requires a PIN to access"...

@poettering
Copy link
Member

But if you turn on debug logs, then you should see more info, that might be helpeful

@poettering
Copy link
Member

https://lore.kernel.org/all/e423eaa2-cf2e-6b3f-dff6-61726cb5c0bf@intel.com/T/

Judging by this this is really about a PIN (i.e. authValue) having been set for the "owner" hierarchy, and not about DA lockout.

@poettering
Copy link
Member

Or in other words you are running into #22129.

On what kind of system did you run into with btw? How come a password was set for owner auth there?

The proper way to fix this is probably by using ask_password_auto() to simply query for the authValue and then use it. But then again, interactivity might suck

@DaanDeMeyer
Copy link
Contributor Author

@poettering The TPM has an auth because we don't want anything messing with it. I should have clarified, but I don't actually want this to work, I couldn't care less about setting up an SRK on these systems, I just want tpm2-setup.service to not fail in these cases.

@poettering
Copy link
Member

So I think we can merge something like this, but please clean up the wording.

I checked the specs btw: while DA lockout mode is on, any attempt to access a DA protected object results in TPM_RC_LOCKOUT. Any attempt to access an object with an authValue set without an authValue or with a TPM_RC_BAD_AUTH error.

hence, what you are doing here is the latter. We probably should have an explict error message /catalog entry for the lockout thing too, but without testing that we shouldn't add this, hence out of scope for now i guess.

But, please reword this, do not say just "locked", that's too misleading.

src/shared/tpm2-util.c Outdated Show resolved Hide resolved
…n failure

The TPM might be password/pin protected for various reasons even if
there is no SRK yet. Let's handle those cases gracefully instead of
failing the unit as it is enabled by default.
@DaanDeMeyer DaanDeMeyer changed the title tpm2-setup: Don't fail if the TPM is locked tpm2-setup: Don't fail if we can't access the TPM due to authorization failure May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
please-review PR is ready for (re-)review by a maintainer tpm2 units util-lib
Development

Successfully merging this pull request may close these issues.

None yet

5 participants