Files
rt-thread/components/drivers/sdio
zhangyangysuandyang.zhang 7e7237d644 Fix stack corruption in rt_sdhci_init_host() (#11542)
* lwp: fix pid leak on exec failure before task startup

When msh tries to execute a non-ELF path, lwp_execve() may allocate a PID
before lwp_load() fails. The old error path only dropped the LWP reference,
leaving the PID tree entry pointing to a freed LWP.

In an init-less boot flow, this can poison pid 1 after a failed command from
msh. A later LWP launch may then treat the stale pid 1 entry as a valid parent
LWP, resulting in invalid pgrp/session state and a job-control assertion during
process exit.

Add lwp_pid_rollback() for exec/spawn failures before the process becomes
runnable. Unlike lwp_pid_put(), it always releases the PID lock and does not
enter the "no more pid allocation" state when the PID tree becomes empty.

Use the rollback helper in lwp_execve() failure paths after PID allocation.

Signed-off-by: zhangyang <gaoshanliukou@163.com>

* [drivers][sdio] avoid SDHCI device name stack overflow

rt_sdhci_init_host() allocated a fixed 32-byte buffer for device-derived object names, but sdio_host_set_name() may copy up to RT_NAME_MAX bytes into the output buffer. When RT_NAME_MAX is larger than 32, this can overwrite the stack and corrupt nearby locals.

Size the temporary name buffer with RT_NAME_MAX, force it to be NUL-terminated, and derive the append offset from the actual string length. Also replace the suffix rt_sprintf() calls with bounded rt_snprintf() so timer and workqueue suffixes cannot overflow the buffer when the base name is already close to RT_NAME_MAX.

Signed-off-by: zhangyangysu <zhangyangysu0928@gmail.com>

---------

Signed-off-by: zhangyang <gaoshanliukou@163.com>
Signed-off-by: zhangyangysu <zhangyangysu0928@gmail.com>
Co-authored-by: yang.zhang <zhangyang01@kylinos.cn>
2026-11-02 11:24:11 +08:00
..
2025-12-26 21:04:42 +08:00
2025-12-26 21:04:42 +08:00