boot: zephyr: Avoid relying on assert statement and add explicit checks#2666
boot: zephyr: Avoid relying on assert statement and add explicit checks#2666namjoshiniks wants to merge 1 commit intomcu-tools:mainfrom
Conversation
b3df3eb to
b573772
Compare
b573772 to
6fa896e
Compare
1679a96 to
ad54782
Compare
de-nordic
left a comment
There was a problem hiding this comment.
This is not a best idea.
When we fail in these places it is not like you can fix a device nor react to the problem, yet these errors will be carried verbatim wasting space on device boot partition.
There is a difference between this issues and when, for example, signature check fails; the later has a chance to happen due to actually bad signature or image and tells you that something may be done to address the problem
If any of fixed errors here happen we have either configuration issue or device is failing anyway and nothing can be done; these are either catch in testing or device can play dead anyway.
Fixes mcu-tools#2661 Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
The problem here is the ASSERT statements get stripped during compile time if DEBUG flag is disabled and CONFIG_ASSERT=n, which is the case in all production projects. If asserts are stripped off, the behavior is undefined and error can go undetected (and possibly a security vulnerability too). As for space, Zephyr based MCUboot is already bulky so a few bytes may not matter. But I do agree, that having string statements for unrecoverable errors that shouldn't really happen in production code is unnecessary. So made the logs to be DBG type logs |
ad54782 to
e3d3919
Compare
Maybe change this to LOG_DBG and panic when tests fail, even when non in debug mode.
They do when they are generally dead code unless unrecoverable problem occurs. And it does matter, because that is space taken out of apps, that is space I am asked to find for customers, that is space that is taking extra time to verify on signature, when mcuboot is protected in other means, this also takes out extra protection bits in soc.
Fine with this. |
Not sure if you got chance to look at the code, but I changed the logging statements to Debug. Additionally, wherever possible I am returning errors (from non void functions or functions that can handle errors gracefully). For void functions, I added FIH_PANIC. |
Avoid relying on assert statement and add explicit checks
Fixes /issues/2661