-
Notifications
You must be signed in to change notification settings - Fork 798
bootutil: Fixed security counter overflow detected to late #2420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bootutil: Fixed security counter overflow detected to late #2420
Conversation
7b100f8
to
cad5f2b
Compare
boot/bootutil/src/image_validate.c
Outdated
@@ -437,6 +437,18 @@ bootutil_img_validate(struct boot_loader_state *state, | |||
goto out; | |||
} | |||
|
|||
#if MCUBOOT_HW_ROLLBACK_PROT_COUNTER_LIMITED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if MCUBOOT_HW_ROLLBACK_PROT_COUNTER_LIMITED | |
#ifdef MCUBOOT_HW_ROLLBACK_PROT_COUNTER_LIMITED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
cad5f2b
to
ecc51f2
Compare
* | ||
* @return FIH_SUCCESS if update is possible; FIH_FAILURE otherwise | ||
*/ | ||
fih_ret boot_nv_security_counter_is_update_possible(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(from the previous comment) this should have the image id I think because there might be multiple counters with different limits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t image_id,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done; I also added img_security_cnt
, the new security counter value - in case the security counter was not only limited by the number of updates, but also by the value of the counter itself (which is a situation described in the psa boot guide)
f8e13fb
to
0f742d1
Compare
This commit fixes the issue, occuring when the maximum amount of security counter updates has been reached. This fact was only detected after a permament update already happened - the updated firmware was unable to boot, as it failed when trying to update the security counter after the permament swap. This commit adds the check if the security counter can be updated (i. e. free security counter slots are still available) before the swap is performed, fixing the issue. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
0f742d1
to
2eb2959
Compare
This commit fixes the issue, occuring when the maximum amount of security counter updates has been reached.
This fact was only detected after a permament update already happened - the updated firmware was unable to boot, as it failed when trying to update the security counter after the permament swap.
This commit adds the check if the security counter can be updated (i. e. free security counter slots are still available) before the swap is performed, fixing the issue.