Commit 891cf0c
committed
Fix TPM counter increment: auth retry on wrong passphrase (TPM1+TPM2)
TPM1: counter_increment fell through to raw 'exec tpm' with no error
handling — a mistyped owner passphrase killed the signing flow instantly.
TPM2: counter_increment had no retry loop, unlike tpm2_seal and
tpm2_counter_create which already re-prompted on auth failure.
Changes:
initrd/bin/tpmr.sh:
- _tpm1_auth_retry: shared retry helper for TPM1 counter create/increment,
re-prompts owner passphrase up to 3× on auth failure, reuses cached
passphrase on first attempt (no double-prompt on happy path)
- tpm1_counter_create / tpm1_counter_increment: thin wrappers around helper
- tpm1_counter_read: named function (was catch-all exec tpm passthrough)
- tpm1_seal: restore define+write retry loop removed by stdout-quirk fix,
definespace output to /dev/null (ignored, nv_writevalue is the real test)
- tpm2_counter_inc: add retry loop with should_retry flag to distinguish
index-auth (-pwdc , no retry) from owner-auth (retry up to 3×)
- All shred calls in retry loops: add 2>/dev/null || true guards
- TPM1 dispatch: wire counter_read, counter_increment to named functions
- TPM1/TPM2 extend/reset: improved PCR INFO messages
initrd/bin/gui-init.sh:
- reset_tpm: verify tpmr.sh reset exit code, show error and return to
menu if reset fails (prevents operations on inconsistent TPM)
initrd/etc/functions.sh:
- increment_tpm_counter: replace misleading outer SINK_LOG with 2>/dev/null
(DO_WITH_DEBUG already captures command stderr via SINK_LOG internally)
- Document DO_WITH_DEBUG stderr handling in comments
doc/tpm.md: document "out of resources" counter error and recovery flow
doc/ux-patterns.md: UX patterns for TPM error recovery
Signed-off-by: Thierry Laurion <insurgo@riseup.net>1 parent bb8c6be commit 891cf0c
7 files changed
Lines changed: 375 additions & 103 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
314 | 337 | | |
315 | 338 | | |
316 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
189 | 209 | | |
190 | 210 | | |
191 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
197 | | - | |
198 | 205 | | |
| 206 | + | |
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| |||
411 | 419 | | |
412 | 420 | | |
413 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
414 | 427 | | |
415 | | - | |
| 428 | + | |
416 | 429 | | |
417 | 430 | | |
418 | 431 | | |
| |||
808 | 821 | | |
809 | 822 | | |
810 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
811 | 827 | | |
812 | | - | |
| 828 | + | |
813 | 829 | | |
814 | 830 | | |
815 | 831 | | |
| |||
839 | 855 | | |
840 | 856 | | |
841 | 857 | | |
842 | | - | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
843 | 870 | | |
844 | 871 | | |
845 | 872 | | |
| |||
0 commit comments