Skip to content

initrd/etc/gpg_functions.sh: check flash.sh exit status before reboot#2114

Merged
tlaurion merged 4 commits into
linuxboot:masterfrom
tlaurion:gpg_inject_on_clean_firmware_flash
May 14, 2026
Merged

initrd/etc/gpg_functions.sh: check flash.sh exit status before reboot#2114
tlaurion merged 4 commits into
linuxboot:masterfrom
tlaurion:gpg_inject_on_clean_firmware_flash

Conversation

@tlaurion
Copy link
Copy Markdown
Collaborator

@tlaurion tlaurion commented May 13, 2026

Fixes #2113

Changes

initrd/etc/gpg_functions.sh

Check flash.sh exit status in gpg_flash_rom(). On success show a
confirmation dialog and reboot automatically; on failure show an
error dialog instead of rebooting unconditionally.

initrd/bin/gui-init.sh

  • Source /etc/gpg_functions.sh for the integrity report helper
  • Add report_integrity_measurements() call before TPM reset paths
    so the user sees current integrity state before deciding to reset
  • Restore /bin/reboot.sh at end of reset_tpm() so the reset flow
    completes with a clean reboot

Copilot AI review requested due to automatic review settings May 13, 2026 20:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the GPG-key-injection-and-reflash flow so that a successful reflash now displays a confirmation dialog and automatically reboots, and adjusts the "Reset the TPM" recovery paths in gui-init.sh to show the integrity report informationally and to reboot at the end of reset_tpm(). This addresses issue #2113, where after reflashing with a new GPG key on a TPM 1.2 maximized board the user was not forced to reboot before regenerating TOTP, leaving the TPM passphrase out of sync.

Changes:

  • After /bin/flash.sh in gpg_flash_rom, show a "ROM Flashed Successfully" message box and call /bin/reboot.sh.
  • Replace the gate_reseal_with_integrity_report || tpm_reset_required gate on the two "Reset the TPM" menu paths with an unconditional report_integrity_measurements call, and update the surrounding comments.
  • Append /bin/reboot.sh at the end of a successful reset_tpm() flow, and source /etc/gpg_functions.sh from gui-init.sh.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
initrd/etc/gpg_functions.sh Adds post-flash success dialog and automatic reboot in gpg_flash_rom.
initrd/bin/gui-init.sh Sources gpg_functions.sh; removes the integrity-gate guard from the two "Reset the TPM" menu paths in favor of an informational integrity report; forces a reboot at the end of reset_tpm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread initrd/etc/gpg_functions.sh Outdated
tlaurion added 4 commits May 13, 2026 16:49
- All three GPG key management paths (gpg_post_gen_mgmt,
  gpg_add_key_reflash, gpg_add_key_to_standalone_rom) call
  gpg_flash_rom() to write the ROM but never call reboot.sh,
  leaving the user in the menu with firmware changes in flash
  that have not taken effect.
- Check /bin/flash.sh exit status: on success show a message
  box and call /bin/reboot.sh; on failure show an error dialog.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- gui-init.sh calls report_integrity_measurements() from
  gui_functions.sh, which at line 488 calls gpg_replace_key_reflash()
  defined in gpg_functions.sh, but gui-init.sh never sourced
  gpg_functions.sh.
- Selecting 'r' (Replace GPG key in current ROM and reflash) from
  the integrity report would fail with an undefined function error.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- The reset_tpm() function clears the TPM owner hierarchy,
  creates new counters, generates new TOTP/HOTP secrets, and
  reseals the disk decryption key, but never reboots after
  completing these changes.
- Add /bin/reboot.sh at the end of the function so the system
  boots into a fresh state with the newly initialized TPM.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
- When TOTP unseal fails and the user selects 'p' (Reset TPM), the
  condition ran gate_reseal_with_integrity_report before reset_tpm.
  The gate forces through update_checksums which needs TPM counter
  operations, requiring the current TPM owner password.  Since the
  TPM has not yet been reset, this password is unknown — creating
  a catch-22: the counter op fails, DIE restarts the boot script,
  and reset_tpm is never reached.
- Same issue in the main menu 'r' (Reset TPM from TPM/TOTP/HOTP
  Options): the gate runs update_checksums before reset_tpm.
- Fix both paths to call report_integrity_measurements directly
  (shows the report without forcing investigation/signing) before
  proceeding to reset_tpm.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
@tlaurion tlaurion force-pushed the gpg_inject_on_clean_firmware_flash branch from 4a1bed6 to e0f0fea Compare May 13, 2026 20:58
@tlaurion tlaurion requested a review from Copilot May 13, 2026 20:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

Comment thread doc/hotp.md Outdated
Comment thread initrd/etc/gpg_functions.sh
@tlaurion
Copy link
Copy Markdown
Collaborator Author

will remove hotp fix and split it in #2115

@tlaurion tlaurion force-pushed the gpg_inject_on_clean_firmware_flash branch from 2548d38 to e0f0fea Compare May 13, 2026 22:55
@tlaurion tlaurion requested a review from Copilot May 13, 2026 22:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

@tlaurion tlaurion changed the title Gpg inject on clean firmware flash fixup initrd/etc/gpg_functions.sh: check flash.sh exit status before reboot May 13, 2026
@notgivenby notgivenby mentioned this pull request May 14, 2026
15 tasks
@tlaurion tlaurion merged commit c1ed061 into linuxboot:master May 14, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with adding gpg key and generating totp on maximized tpm1.2 board without factory reset

2 participants