Definition
A last-known-good state is the most recent version of a system’s software or configuration that has passed a defined success test and is kept intact so that the system can return to it when a newer version fails. The success test, for example starting correctly and then reaching the server that delivers updates, is what makes the version known good. Being older, having been installed before, or passing a signature check does not. It is the usual target when a system falls back after a failed update.
The idea
A device runs firmware version 8, which fails, and returns to version 7, its last-known-good state. The label suggests that version 7 will work. What supports that? Version 7 passed its tests months ago, with that day’s hardware, stored data, keys and servers. If version 8 has since converted the stored settings to a format that version 7 cannot read, or the key that version 7 uses to reach its server has been withdrawn, version 7 is no longer good in the conditions it would now run in.
Microsoft Windows, in versions up to Windows 7, offered a start-up option named Last Known Good Configuration. It restored the settings saved at the last successful start that choose which drivers, the programs that operate hardware, and which background services start, and Windows counted a start as successful once its drivers and services had loaded and a user had logged on. The rule shows the general point. “Known good” means good by a stated test, here a successful logon, and a setting that let a user log on but broke something else would still have been saved as known good.
A last-known-good state is therefore two things: a recorded fact and a preserved environment. The fact is that a named version passed a named test. The environment is everything that test depended on, which must still be present when the system falls back. A spare tire is a fair picture: it is a fallback only if it was checked, is still inflated and fits the wheels. The picture stops at change over time. A tire’s fit does not change by itself, while software’s dependencies change with every update.
How it works
A system keeps a usable last-known-good state in seven steps.
Define the success test. State what a version must show before it counts as good, for example: its image, the stored program, passed verification of its digital signature §5.14, it started, its self-tests passed, and it completed the function that must not break, such as reaching the update server and accepting a test command. This is the same test that a commit-confirmed update §8.23 uses for its confirmation.
Record the result. When a version passes, write a durable record, one that survives a loss of power, that ties the result to the exact version by its version number and a cryptographic hash §5.1 of its bytes. In an A/B update §8.10 this is the confirmed flag in the slot’s record.
Preserve the version. Keep its bytes untouched while a newer version is on trial: do not erase its slot, and do not let garbage collection §8.16 reclaim its storage.
Preserve its dependencies. Keep the data formats it reads, the keys it needs and its configuration. A newer version that converts stored data writes the converted copy beside the old one, and the old copy stays until the newer version is itself confirmed; the Schema migration §8.36 entry treats this.
Keep it allowed. If the device refuses versions below a stored version floor, raise the floor past the old version only after the newer version is confirmed. Raising it earlier forbids the fallback.
Promote. When a newer version passes the test, it becomes the last-known-good state, and the older version may be released.
Recheck at fallback. Before using the fallback, check what could have changed since it was tested: the integrity §1.9 of its bytes, the version floor, and whether its keys have been revoked. If no version passes, enter a defined recovery mode instead of guessing.
Worked example
A device runs firmware version 7, confirmed on 1 March after it started, passed its self-tests and reached the update server. Its settings are stored in format 1 and take 2 KiB.
An unsafe update. Version 8 starts on trial. At its first start it converts the settings in place to format 2, which takes 3 KiB, and raises the version floor from 7 to 8. Version 8 crashes at its third start. The bootloader §6.30, the program that chooses what to start after a reset, tries to fall back to version 7 and meets two obstacles. Since , the floor forbids version 7. And even if version 7 were allowed, it could not read format 2. Version 7 was known good on 1 March, but none of the conditions it was tested under remain, and the device has no usable fallback.
A safe update. Version 8 writes the format-2 settings to a new area and leaves the format-1 copy intact, so the settings take KiB during the trial. The floor stays at 7. When version 8 crashes, the bootloader starts version 7, which is allowed because , and version 7 reads its intact format-1 settings. Only after version 8 is confirmed does the device raise the floor to 8, release the format-1 copy, leaving KiB in use, and make version 8 the last-known-good state. Settings changed while version 8 was on trial exist only in format 2. They are lost on fallback unless the design copies them back.
Stated precisely
Let be the declared success test, a version and the current time. Version is the last-known-good state at time when five conditions hold.
Evidence. A durable record states that , identified by its cryptographic hash, passed at an earlier time , under a set of conditions: the hardware, the stored data format, the keys and the configuration present at .
Recency. No version newer than has passed since .
Intact. The stored bytes of still match the recorded hash.
Compatible. Every condition in that needs still holds at .
Allowed. The device’s rules permit to run at : its version is at or above the stored version floor, and its signing key has not been revoked.
Conditions 1 and 2 make known good. Conditions 3 to 5 make it usable now. The evidence supports only this conclusion: in conditions that match , has been observed to pass . It says nothing about behavior that did not check.
Limits and common mistakes
Known good does not mean free of faults. The test covered what it covered, and a fault that the test did not exercise is still in the fallback.
Previously installed does not mean known good. An image that was written and started but never confirmed has no evidence behind it.
Falling back to an old version brings back its known security flaws. That is why devices keep a version floor, and why the floor and the fallback conflict; the Rollback versus anti-rollback §8.26 entry treats the conflict.
The world outside the device changes too. A server may stop accepting an old protocol version, and a certificate, a signed statement that binds a key to a name, built into the old version may expire, so a fallback that runs correctly can still fail to reach anything.
Work done during the trial can be lost on fallback, as the settings in the example show.
A single last-known-good copy is a single point of failure. If its storage is damaged, the device needs a further fallback, such as a factory image or a recovery mode.
Questions answered
What evidence made the previous state known good?
The evidence is a durable record that the previous version passed a declared success test after it was installed: for example, that it started, passed its self-tests and completed the function that must not break, such as reaching the update server and accepting the next update. The record ties that result to the exact version by its version number and a cryptographic hash of its bytes. A last-known-good state is the most recent version with such evidence, kept intact so that the system can return to it. Being older, having been installed, or passing a signature check is not such evidence.
The evidence covers only the conditions present when the test ran: the stored data format, the keys, the configuration and the hardware. Before falling back, the system checks that the version’s bytes are intact, that the version is still allowed to run (not below the stored version floor, and its signing key not revoked), and that the data and keys it depends on are still present.
Related entries: Commit-confirmed update (§8.23), Rollback versus anti-rollback (§8.26), Recovery fallback (§8.29), Key confirmation versus application confirmation (§5.42), A/B update (§8.10), Schema migration (§8.36), Version high-water mark (§8.27).