Skip to content
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

[flash_ctrl] Relax the hardening in flash_ctrl_data_region_protect #26034

Open
wants to merge 1 commit into
base: earlgrey_1.0.0
Choose a base branch
from

Conversation

cfrantz
Copy link
Contributor

@cfrantz cfrantz commented Jan 27, 2025

The hardening in the function flash_ctrl_data_region_protect resulted in 1304 bytes of RV32 machine code. This relaxed version results in 250 bytes of RV32 machine code.

@cfrantz cfrantz requested a review from a team as a code owner January 27, 2025 19:35
@cfrantz cfrantz removed the request for review from a team January 27, 2025 19:35
// Reset the region's configuration via the MP_REGION_CFG_${region} register.
// This temporarily disables memory protection for the region.
flash_ctrl_mp_region_cfg_reset(region);
sec_mmio_write32(kBase + FLASH_CTRL_MP_REGION_CFG_0_REG_OFFSET + region,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider adding a SEC_MMIO_ASSERT_WRITE_INCREMENT() to keep track of the sec_mmio counter increment.

I am not sure if we are doing any sec_mmio checks in the rom_ext after ownership commands have been executed. This is something we can discuss as a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think this one should be abs_mmio_write32. That way, if an adversary could somehow early-return from this function before writing the new region config, a check would fail later.

But, I agree, the two sec_mmio writes at the bottom should probably have increments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I think we can do this in a follow up PR once we review the sec_mmio hardening for the ROM_EXT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@cfrantz cfrantz force-pushed the flash_ctrl-region-protect branch 2 times, most recently from 4d2709b to 37da31e Compare January 29, 2025 16:04
The hardening in the function `flash_ctrl_data_region_protect` resulted
in 1304 bytes of RV32 machine code.  This relaxed version results in
250 bytes of RV32 machine code.

Signed-off-by: Chris Frantz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants