Skip to content

Fault injection protection - #50

Merged
JamesHuard merged 8 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
diondokter:fault-injection-protection
Oct 19, 2026
Merged

JamesHuard merged 8 commits into
OpenDevicePartnership:mcxa-secure-bootfrom
diondokter:fault-injection-protection

Conversation

@diondokter

@diondokter diondokter commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Please review (and merge) #49 first.
This PR builds on top of it

This PR adds a protectec-if routine that protects against single instruction fault injection.

@diondokter
diondokter requested a review from a team as a code owner October 13, 2026 17:22
@diondokter
diondokter changed the base branch from main to mcxa-secure-boot October 13, 2026 17:22
@jerrysxie
jerrysxie requested a review from felipebalbi October 13, 2026 17:23
@jerrysxie jerrysxie added this to EC Oct 13, 2026
(cherry picked from commit 160db31)
(cherry picked from commit 5c37dcb)
(cherry picked from commit 6f054d6)
(cherry picked from commit ef4838c)
@diondokter
diondokter force-pushed the fault-injection-protection branch from 12ec658 to 6330714 Compare October 13, 2026 18:13
(cherry picked from commit 12ec658)
@diondokter
diondokter force-pushed the fault-injection-protection branch from 6330714 to 32d027f Compare October 13, 2026 18:14
Comment thread libs/fault-rejection/src/lib.rs Resolved
@JamesHuard
JamesHuard enabled auto-merge (squash) October 15, 2026 16:07
@JamesHuard
JamesHuard merged commit 35abfa6 into OpenDevicePartnership:mcxa-secure-boot Oct 19, 2026
8 of 9 checks passed
@github-project-automation github-project-automation Bot moved this from Committed to Done in EC Oct 19, 2026
@alamfarjadf

Copy link
Copy Markdown

@felipebalbi @diondokter @JamesHuard This branch does not work. Pretty sure the registers are getting clobbered and are causing all sorts of unexpected behaviors. We need to revert the merge.

I do have additional questions/concerns about the fault paths as well.

@alamfarjadf

Copy link
Copy Markdown

One of the bigger concerns apart from the assembly itself: Seems like there is no protection around actual dev_mode detection (hinged on a single bit at its weakest without any guards). So, one fault in the actual dev_mode selection (SB turned on detection from OnlyPki) itself could make the MCU legitimately believe it's truly in DEV mode, without the need to fault any of the load bearing follow up branches.

Something else of concern (related, but minor): I know we explicitly set the CMPA security settings to all zeros in our provisioner, but no one is required to use it. And all erased CMPA with a valid header actually decodes as OnlyPki b11; not a realistic scenario with our provisioner but in that case it's basically always legitimately in DEV mode ALL THE TIME.

@alamfarjadf

Copy link
Copy Markdown

There was some logic in my original PR for protecting (or attempting to protect) the integrity of the data that drives the dev_mode decision. Their usefulness can be up for debate, but I'd image something to that effect would be needed (if not something completely different).

@diondokter

Copy link
Copy Markdown
Member Author

Got the fix here: #55
No need to revert as that should fix the issue

JamesHuard pushed a commit that referenced this pull request Oct 23, 2026
…ten in fault rejection (#55)

This should fix what @alamfarjadf saw here:
#50 (comment)

What happened was that one of the allocated registers was the LR
register. I don't know why that's being picked as it sounds like a
terrible choice.
The value would get overwritten by the first `bl` instruction which
caused the `body` closure to not get called (properly).

By allocating the registers manually, we know they're ok to use. In the
disassembly I can also see these registers are pushed and popped to/from
the stack as they should.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants