Skip to content

Commit b8801fc

Browse files
kasjerd3zd3z
authored andcommitted
zephyr/Kconfig: Add downgrade prevention to swaps
Downgrade prevention for swap upgrades that was added to mcuboot is now configurable in zephyr. It may be using software version number from image in slot 0, or security counter from the image in slot 0 (for limited downgrade availability). Hardware base security counter check remains unchanged. Signed-off-by: Jerzy Kasenberg <[email protected]>
1 parent e3f895d commit b8801fc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

boot/zephyr/Kconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,25 @@ choice BOOT_DOWNGRADE_PREVENTION_CHOICE
548548

549549
config MCUBOOT_DOWNGRADE_PREVENTION
550550
bool "SW based downgrade prevention"
551-
depends on BOOT_UPGRADE_ONLY
551+
depends on !BOOT_DIRECT_XIP
552552
help
553553
Prevent downgrades by enforcing incrementing version numbers.
554554
When this option is set, any upgrade must have greater major version
555555
or greater minor version with equal major version. This mechanism
556556
only protects against some attacks against version downgrades (for
557557
example, a JTAG could be used to write an older version).
558558

559+
config MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER
560+
bool "Use image security counter instead of version number"
561+
depends on MCUBOOT_DOWNGRADE_PREVENTION
562+
depends on (BOOT_SWAP_USING_MOVE || BOOT_SWAP_USING_SCRATCH)
563+
help
564+
Security counter is used for version eligibility check instead of pure
565+
version. When this option is set, any upgrade must have greater or
566+
equal security counter value.
567+
Because of the acceptance of equal values it allows for software
568+
downgrades to some extent.
569+
559570
config MCUBOOT_HW_DOWNGRADE_PREVENTION
560571
bool "HW based downgrade prevention"
561572
help

boot/zephyr/include/mcuboot_config/mcuboot_config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@
133133

134134
#ifdef CONFIG_MCUBOOT_DOWNGRADE_PREVENTION
135135
#define MCUBOOT_DOWNGRADE_PREVENTION 1
136+
/* MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER is used later as bool value so it is
137+
* always defined, (unlike MCUBOOT_DOWNGRADE_PREVENTION which is only used in
138+
* preprocessor condition and my be not defined) */
139+
# ifdef CONFIG_MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER
140+
# define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 1
141+
# else
142+
# define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 0
143+
# endif
136144
#endif
137145

138146
#ifdef CONFIG_MCUBOOT_HW_DOWNGRADE_PREVENTION

0 commit comments

Comments
 (0)