Commit 0561b83
committed
initrd: fix TPM1 counter auth regression and defend lock cascade failure
PR #2068 (tpm_reseal_ux-integrity_report-detect_disk_and_tpm_swap,
merged at d3d8053) changed increment_tpm_counter from hardcoded
-pwdc '' (empty counter auth) to -pwdc "${tpm_passphrase:-}" (owner
passphrase from cache/prompt), but left check_tpm_counter using empty
-pwdc when called from kexec-sign-config.sh without a $3 passphrase
argument. 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 x ~5 boots via the
_tpm_auth_retry loop) triggered TPM 1.2 dictionary-attack lockout
(TPM_DEFEND_LOCK_RUNNING), which persisted through forceclear on
some implementations, causing tpm takeown to fail and TPM reset to
abort - a cascade failure from the counter auth mismatch.
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; full AC power cycle remains the fallback if software
presence is insufficient
- initrd/bin/tpmr.sh (tpm1_counter_increment): detect -pwdc '' and
call tpm directly, bypassing _tpm_auth_retry which injected the
owner passphrase. Use || return to survive set -e on expected
auth failure.
- initrd/etc/functions.sh (check_tpm_counter): pass -pwdc '' instead
of -pwdc "${tpm_passphrase:-}" so counters use SHA1("") per TCG
spec. Document that $3 is intentionally ignored.
- initrd/etc/functions.sh (increment_tpm_counter): try -pwdc '' first
for TPM1. If that fails on a readable counter (created by PR #2068
era code), prompt for owner passphrase and retry as migration
fallback with clear WARN explaining the one-time migration and
TPM reset option.
- initrd/etc/functions.sh (increment_tpm_counter): remove the
TPM1-specific owner-passphrase prompt block added by PR #2068
- initrd/etc/functions.sh (increment_tpm_counter): DIE-path fallback
counter_create: -pwdc '' for consistency
- initrd/bin/oem-factory-reset.sh: counter_create -pwdc '' for
consistency with the empty-auth design
- 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 0561b83
4 files changed
Lines changed: 185 additions & 32 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 | |
|---|---|---|---|
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
| 871 | + | |
872 | 872 | | |
873 | 873 | | |
874 | 874 | | |
| |||
| 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 | | |
| |||
443 | 453 | | |
444 | 454 | | |
445 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
446 | 462 | | |
447 | 463 | | |
448 | 464 | | |
| 465 | + | |
| 466 | + | |
449 | 467 | | |
450 | 468 | | |
451 | 469 | | |
452 | | - | |
| 470 | + | |
453 | 471 | | |
454 | 472 | | |
455 | 473 | | |
456 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
457 | 483 | | |
458 | 484 | | |
459 | 485 | | |
| |||
641 | 667 | | |
642 | 668 | | |
643 | 669 | | |
644 | | - | |
| 670 | + | |
645 | 671 | | |
646 | 672 | | |
647 | 673 | | |
| |||
759 | 785 | | |
760 | 786 | | |
761 | 787 | | |
762 | | - | |
| 788 | + | |
763 | 789 | | |
764 | 790 | | |
765 | 791 | | |
| |||
788 | 814 | | |
789 | 815 | | |
790 | 816 | | |
791 | | - | |
| 817 | + | |
792 | 818 | | |
793 | 819 | | |
794 | 820 | | |
| |||
1075 | 1101 | | |
1076 | 1102 | | |
1077 | 1103 | | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
1081 | 1132 | | |
1082 | 1133 | | |
1083 | 1134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1848 | 1848 | | |
1849 | 1849 | | |
1850 | 1850 | | |
1851 | | - | |
| 1851 | + | |
| 1852 | + | |
1852 | 1853 | | |
1853 | 1854 | | |
1854 | 1855 | | |
| |||
1872 | 1873 | | |
1873 | 1874 | | |
1874 | 1875 | | |
1875 | | - | |
| 1876 | + | |
1876 | 1877 | | |
1877 | 1878 | | |
1878 | 1879 | | |
| |||
2051 | 2052 | | |
2052 | 2053 | | |
2053 | 2054 | | |
| 2055 | + | |
| 2056 | + | |
2054 | 2057 | | |
2055 | 2058 | | |
2056 | 2059 | | |
2057 | 2060 | | |
2058 | 2061 | | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
2071 | 2062 | | |
2072 | 2063 | | |
2073 | 2064 | | |
| |||
2094 | 2085 | | |
2095 | 2086 | | |
2096 | 2087 | | |
2097 | | - | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
2098 | 2093 | | |
2099 | 2094 | | |
2100 | 2095 | | |
| |||
2104 | 2099 | | |
2105 | 2100 | | |
2106 | 2101 | | |
2107 | | - | |
| 2102 | + | |
2108 | 2103 | | |
2109 | 2104 | | |
2110 | 2105 | | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
2111 | 2121 | | |
2112 | 2122 | | |
2113 | 2123 | | |
| |||
2126 | 2136 | | |
2127 | 2137 | | |
2128 | 2138 | | |
2129 | | - | |
| 2139 | + | |
2130 | 2140 | | |
2131 | 2141 | | |
2132 | 2142 | | |
| |||
0 commit comments