Commit c20cd28
committed
initrd: fix TPM1 counter auth regression and defend lock cascade failure
Commit 5168be2494 (PR #2035) changed increment_tpm_counter to pass the
TPM owner passphrase as the TPM1 counter's auth value (-pwdc), but
check_tpm_counter was left using empty auth (-pwdc ''). This caused
every counter increment to compute SHA1(owner_pass) while the counter
was created with SHA1("") — persistent TPM_AUTH_FAIL.
Per TCG TPM Main Spec Part 3, TPM_CreateCounter uses owner auth
(-pwdo) but TPM_IncrementCounter uses the counter's own authData,
not the owner password. The correct design for Heads' rollback
counter is empty auth: rollback security comes from the signed
/boot/kexec_rollback.txt and TPM sealing, not counter access control.
The repeated auth failures (3 per boot × ~5 boots) triggered TPM 1.2
dictionary-attack lockout (TPM_DEFEND_LOCK_RUNNING), which persisted
through forceclear on some implementations, causing subsequent
tpm takeown to fail and TPM reset to abort.
Changes:
- initrd/bin/tpmr.sh (_tpm_auth_retry, tpm2_counter_inc, tpm2_seal,
tpm1_seal): add 'defend' and '0x98e|0x149' to auth detection grep
patterns so defend lock and TPM2 RC codes are treated as retryable
auth failures rather than fatal errors
- initrd/bin/tpmr.sh (tpm1_reset): detect "defend lock" after takeown
failure and cycle physical presence to clear the lock state before
retrying — a full AC power cycle remains the fallback if software
presence is insufficient
- initrd/etc/functions.sh (check_tpm_counter): pass -pwdc '' (empty
counter auth) instead of -pwdc "${tpm_passphrase:-}" so the counter
is created with SHA1("") per TCG spec
- initrd/etc/functions.sh (increment_tpm_counter): try -pwdc '' first
for TPM1 (correct behavior). If that fails on a readable counter
(created by the buggy inter-version code), prompt for owner
passphrase and retry as migration fallback
- initrd/etc/functions.sh (increment_tpm_counter): remove the
TPM1-specific owner-passphrase prompt block added by the regression
— no longer needed as new counters use empty auth
- doc/tpm.md: document TPM1 boot chain, tpmtotp tool selection,
auth retry patterns, defend lock recovery, and physical presence
Signed-off-by: Thierry Laurion <insurgo@riseup.net>1 parent 7d3a28a commit c20cd28
3 files changed
Lines changed: 163 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
15 | 42 | | |
16 | 43 | | |
17 | 44 | | |
| |||
398 | 425 | | |
399 | 426 | | |
400 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
373 | 383 | | |
374 | 384 | | |
375 | | - | |
| 385 | + | |
376 | 386 | | |
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
380 | 390 | | |
381 | 391 | | |
382 | | - | |
| 392 | + | |
383 | 393 | | |
384 | 394 | | |
385 | 395 | | |
| |||
417 | 427 | | |
418 | 428 | | |
419 | 429 | | |
420 | | - | |
| 430 | + | |
421 | 431 | | |
422 | 432 | | |
423 | 433 | | |
| |||
641 | 651 | | |
642 | 652 | | |
643 | 653 | | |
644 | | - | |
| 654 | + | |
645 | 655 | | |
646 | 656 | | |
647 | 657 | | |
| |||
759 | 769 | | |
760 | 770 | | |
761 | 771 | | |
762 | | - | |
| 772 | + | |
763 | 773 | | |
764 | 774 | | |
765 | 775 | | |
| |||
788 | 798 | | |
789 | 799 | | |
790 | 800 | | |
791 | | - | |
| 801 | + | |
792 | 802 | | |
793 | 803 | | |
794 | 804 | | |
| |||
1075 | 1085 | | |
1076 | 1086 | | |
1077 | 1087 | | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
1081 | 1116 | | |
1082 | 1117 | | |
1083 | 1118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1872 | 1872 | | |
1873 | 1873 | | |
1874 | 1874 | | |
1875 | | - | |
| 1875 | + | |
1876 | 1876 | | |
1877 | 1877 | | |
1878 | 1878 | | |
| |||
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| 2054 | + | |
| 2055 | + | |
2054 | 2056 | | |
2055 | 2057 | | |
2056 | 2058 | | |
2057 | 2059 | | |
2058 | 2060 | | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
2071 | 2061 | | |
2072 | 2062 | | |
2073 | 2063 | | |
| |||
2094 | 2084 | | |
2095 | 2085 | | |
2096 | 2086 | | |
2097 | | - | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
2098 | 2092 | | |
2099 | 2093 | | |
2100 | 2094 | | |
| |||
2104 | 2098 | | |
2105 | 2099 | | |
2106 | 2100 | | |
2107 | | - | |
| 2101 | + | |
2108 | 2102 | | |
2109 | 2103 | | |
2110 | 2104 | | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
2111 | 2120 | | |
2112 | 2121 | | |
2113 | 2122 | | |
| |||
0 commit comments