refactor(core): remove cyclic dependency - display_rsod_rust
What changed, and why it matters
This commit is a straightforward code cleanup. It removes a header file include in a C file and replaces it with a direct declaration of a Rust-implemented function, while removing that same declaration from a shared header. The change breaks a circular dependency between the low-level graphics code and the Rust UI layer. There is no functional change to how errors are displayed, no bug fix, and no security-relevant behavior change.
No security action required. Treat as a normal refactoring review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes #include 'rust_ui_common.h' from core/embed/io/gfx/rsod.c and instead declares display_rsod_rust directly with extern. The declaration is also removed from core/embed/rust/rust_ui_common.h. This decouples the RSOD (Red Screen of Death) C implementation from the Rust UI common header, eliminating a build-level cyclic dependency. The TODO comment explicitly notes the architectural layering concern but does not indicate a vulnerability. No code logic, bounds handling, or call semantics are altered.
Changed components
core/embed/io/gfx/rsod.ccore/embed/rust/rust_ui_common.hInspect captured patch +5 / −4
diff --git a/core/embed/io/gfx/rsod.c b/core/embed/io/gfx/rsod.c
index b8ca4e4f..3d4a4939 100644
--- a/core/embed/io/gfx/rsod.c
+++ b/core/embed/io/gfx/rsod.c
@@ -124,7 +124,11 @@ void rsod_terminal(const systask_postmortem_t* pminfo) {
#ifdef FANCY_FATAL_ERROR
-#include "rust_ui_common.h"
+// `display_rsod_rust` is implemented in Rust and called from C.
+// TODO: This jumps from a lower layer to a higher one. Consider registering
+// a callback instead of calling in the reverse direction.
+extern void display_rsod_rust(const char* title, const char* message,
+ const char* footer);
void rsod_gui(const systask_postmortem_t* pminfo) {
const char* title = RSOD_DEFAULT_TITLE;
diff --git a/core/embed/rust/rust_ui_common.h b/core/embed/rust/rust_ui_common.h
index cf4effa9..e51e3f6b 100644
--- a/core/embed/rust/rust_ui_common.h
+++ b/core/embed/rust/rust_ui_common.h
@@ -1,8 +1,5 @@
#include <trezor_types.h>
-void display_rsod_rust(const char* title, const char* message,
- const char* footer);
-
void screen_boot_stage_2(bool fade_in);
void screen_update(void);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.