feat(core): update rgb_led syscall stubs.
What changed, and why it matters
This commit updates the Trezor firmware's RGB LED system-call interface. It adds two new kernel calls (effect_start and effect_stop), exposes them to Rust code, and removes a redundant negative-value check in the effect lookup. The change is a feature update with a minor hardening cleanup; there is no direct evidence it fixes an exploitable security bug.
Treat as a routine feature/maintenance commit. Review the new syscalls for argument validation and ensure `rgb_led_effect_start` enforces the same bounds on `effect_type` as `rgb_led_assign_effect`. No urgent security action is indicated by the diff alone.
Security signals we found
Removal of a redundant negative bound check on an unsigned enum (defense-in-depth cleanup, not a vulnerability fix)
Addition of new syscalls expanding the kernel attack surface for RGB LED control
No input validation visible in the new syscall dispatch paths beyond type casting
Evidence from the diff
The patch extends the syscall table and dispatch/stub code for RGB LED effects on STM32, allowing user-space (including Rust) to start/stop LED effects. It also removes effect_type < 0 from the bounds check in rgb_led_assign_effect() because rgb_led_effect_type_t is an unsigned enum, making that branch always false. The rest of the change is documentation typo fixes and Rust binding allowlisting.
Changed components
core/embed/io/rgb_led/stm32u5/rgb_led_effects.ccore/embed/sys/syscall/inc/sys/syscall_numbers.hcore/embed/sys/syscall/stm32/syscall_dispatch.ccore/embed/sys/syscall/stm32/syscall_stubs.ccore/embed/rust/build.rscore/embed/projects/prodtest/README.mdInspect captured patch +29 / −3
diff --git a/core/embed/io/rgb_led/stm32u5/rgb_led_effects.c b/core/embed/io/rgb_led/stm32u5/rgb_led_effects.c
index a9d8c29fd..b58011df2 100644
--- a/core/embed/io/rgb_led/stm32u5/rgb_led_effects.c
+++ b/core/embed/io/rgb_led/stm32u5/rgb_led_effects.c
@@ -78,7 +78,7 @@ static uint32_t rgb_led_linear_effect(uint32_t c_start, uint32_t c_end,
// Assign effect callback from the lookup table
bool rgb_led_assign_effect(rgb_led_effect_t *effect,
rgb_led_effect_type_t effect_type) {
- if (effect_type < 0 || effect_type >= RGB_LED_NUM_OF_EFFECTS) {
+ if (effect_type >= RGB_LED_NUM_OF_EFFECTS) {
return false;
}
diff --git a/core/embed/projects/prodtest/README.md b/core/embed/projects/prodtest/README.md
index 0cb195ba9..ae1374f32 100644
--- a/core/embed/projects/prodtest/README.md
+++ b/core/embed/projects/prodtest/README.md
@@ -542,7 +542,7 @@ OK
```
### rgbled-effect-start
-Start the rgb effect from the predifined list. Command takes two arguments, first argument define a number of the rgbled effect, second argument then define number of requested cycles for which the effect should run. `requested_cycles` argument is optional, calling the command without it will run effect indefinitly.
+Start the rgb effect from the predefined list. Command takes two arguments, first argument defines a number of the rgbled effect, second argument then defines number of requested cycles for which the effect should run. `requested_cycles` argument is optional, calling the command without it will run effect indefinitely.
`rgbled-effect-start <effect_num> <requested_cycles>`
@@ -554,7 +554,7 @@ OK
```
### rgbled-effect-stop
-stop the ongoing rgbled effect.
+Stop the ongoing rgbled effect.
Examples:
```
diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs
index 21f7068ae..75c60bf35 100644
--- a/core/embed/rust/build.rs
+++ b/core/embed/rust/build.rs
@@ -399,7 +399,10 @@ fn generate_trezorhal_bindings() {
// random
.allowlist_function("random_uniform")
// rgb led
+ .allowlist_type("rgb_led_effect_type_t")
.allowlist_function("rgb_led_set_color")
+ .allowlist_function("rgb_led_effect_start")
+ .allowlist_function("rgb_led_effect_stop")
// systick
.allowlist_function("systick_delay_ms")
.allowlist_function("systick_ms")
diff --git a/core/embed/sys/syscall/inc/sys/syscall_numbers.h b/core/embed/sys/syscall/inc/sys/syscall_numbers.h
index c49c07184..340369c1c 100644
--- a/core/embed/sys/syscall/inc/sys/syscall_numbers.h
+++ b/core/embed/sys/syscall/inc/sys/syscall_numbers.h
@@ -87,6 +87,8 @@ typedef enum {
SYSCALL_RGB_LED_SET_ENABLED,
SYSCALL_RGB_LED_GET_ENABLED,
SYSCALL_RGB_LED_SET_COLOR,
+ SYSCALL_RGB_LED_EFFECT_START,
+ SYSCALL_RGB_LED_EFFECT_STOP,
SYSCALL_HAPTIC_SET_ENABLED,
SYSCALL_HAPTIC_GET_ENABLED,
diff --git a/core/embed/sys/syscall/stm32/syscall_dispatch.c b/core/embed/sys/syscall/stm32/syscall_dispatch.c
index 388fcc2a0..7de0d37b7 100644
--- a/core/embed/sys/syscall/stm32/syscall_dispatch.c
+++ b/core/embed/sys/syscall/stm32/syscall_dispatch.c
@@ -337,6 +337,16 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
uint32_t color = args[0];
rgb_led_set_color(color);
} break;
+
+ case SYSCALL_RGB_LED_EFFECT_START: {
+ rgb_led_effect_type_t effect_type = (rgb_led_effect_type_t)args[0];
+ uint32_t requested_cycles = args[1];
+ rgb_led_effect_start(effect_type, requested_cycles);
+ } break;
+
+ case SYSCALL_RGB_LED_EFFECT_STOP: {
+ rgb_led_effect_stop();
+ } break;
#endif
#ifdef USE_HAPTIC
diff --git a/core/embed/sys/syscall/stm32/syscall_stubs.c b/core/embed/sys/syscall/stm32/syscall_stubs.c
index ed7b3750e..5230f910a 100644
--- a/core/embed/sys/syscall/stm32/syscall_stubs.c
+++ b/core/embed/sys/syscall/stm32/syscall_stubs.c
@@ -322,6 +322,17 @@ void rgb_led_set_color(uint32_t color) {
syscall_invoke1(color, SYSCALL_RGB_LED_SET_COLOR);
}
+void rgb_led_effect_start(rgb_led_effect_type_t effect_type,
+ uint32_t requested_cycles) {
+ syscall_invoke2((uint32_t)effect_type, requested_cycles,
+ SYSCALL_RGB_LED_EFFECT_START);
+}
+
+/**
+ * @brief Stop the currently running RGB led effect and turn off the RGB led
+ */
+void rgb_led_effect_stop(void) { syscall_invoke0(SYSCALL_RGB_LED_EFFECT_STOP); }
+
#endif
// =============================================================================
Why this scored 19/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.