[Bug] FinSH console command lacks asynchronous-safe attribute validation
Maintainer antworten meist innerhalb von 2 Tagen
@BernardXiong arbeitet bereits daran.
Seit 09.6.2026.
- #11455 von @copilot-swe-agent — ohne Merge geschlossen
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
RT-Thread Version
v5.3.0/git-hash: cda0a63ab56d9b46577a58958cb01418e2d668f2
Hardware Type/Architectures
bsp/stm32/stm32f407-atk-explorer
Develop Toolchain
GCC
Describe the bug
Description
In the RT-Thread FinSH component, the console command allows users to dynamically switch the system's log output device at runtime. However, the command's handling logic (and the underlying rt_console_set_device API) only checks if the target device exists, completely failing to validate whether the target device possesses asynchronous-safe attributes or supports interrupt context output (e.g., RT_DEVICE_FLAG_INT_TX).
rt_kprintf is a core logging interface in the RTOS, frequently used within hardware Interrupt Service Routines (ISRs) and low-level kernel assertions. If an attacker or an unaware user redirects the console to a blocking peripheral that internally uses rt_mutex (e.g., I2C, SPI, or certain virtual network devices) via the console command, the system state is "poisoned" (State Poisoning / Type Confusion).
In this state, any subsequent rt_kprintf called from within an ISR (such as a Warning triggered by a peripheral buffer overflow) will trigger the kernel IPC's interrupt safety check assertion. This assertion attempts to print another error using rt_kprintf, causing an infinite recursion and severe memory corruption (Stack Clash), which leads to an instant HardFault (DoS).
Prerequisites to Reproduce
- The FinSH component and the
consolecommand are enabled. - A registered device with blocking lock logic (e.g., a device named
i2c1orspi1) exists in the system.
Steps to Reproduce
- Boot the RT-Thread system and enter the FinSH interactive shell.
- Execute the console redirection command, targeting any slow, blocking device:
msh > console i2c1 - The system state is now poisoned. Next, trigger any code path that calls
rt_kprintforLOG_Wfrom within an ISR (for example, flood the UART with garbage data at a high baud rate to trigger a UART RX Buffer Overflow warning). rt_kprintfroutes the warning to the I2C device, and the I2C driver attempts to acquire anrt_mutexinside the ISR.- The kernel IPC check (
RT_DEBUG_SCHEDULER_AVAILABLE) detects the interrupt context violation and callsrt_kprintfto report the error. - This forms an infinite recursive deadlock between
rt_kprintfand_rt_mutex_take, instantly exhausting stack memory and crashing the device.
Root Cause Analysis (Code Level)
There is a typical device type and attribute validation missing in the source code handling the console command and rt_console_set_device().
The current implementation merely confirms the device exists via rt_device_find(name) and directly switches the pointer:
/* Abstract of the current vulnerable logic */
rt_device_t dev = rt_device_find(name);
if (dev != RT_NULL)
{
rt_console_set_device(name); // Blind switch, no attribute validation
}
### Other additional context
_No response_
- Vorherrschende Sprache
- C
- Sterne
- 12.4k
- Forks
- 5.5k
- Ø Merge
- 3 T. 7 Std.
- Gemergte PRs (30 T.)
- 79
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RT-Thread/rt-thread
-
Arch: ARM/AArch64 Doc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
RT-Thread/rt-thread#12082 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
RT-Thread/rt-thread#11951 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
[Bug] [libc] timer_gettime 拆秒前将总纳秒截断为 uint32_t,剩余时间查询错误Evtl. wieder frei @Yunlk hat das vor 28 Tagen übernommen, und es ist kein Pull Request offen. Offenin progress
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
RT-Thread/rt-thread#11924 · 7 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
[Bug] dfs_v2 tmpfs: ftruncate(fd, 0) frees the file buffer but reports success — use-after-free read/write and double free from a legal POSIX callEvtl. vergeben @remukisama hat das vor 33 Tagen übernommen. Offenin progress
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
RT-Thread/rt-thread#11902 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
[bsp][stm32][bluepill] README「快速上手」缺少重新生成 MDK 工程这一步,按文档操作无法编译通过Evtl. wieder frei @moment-NEW hat das vor 50 Tagen übernommen, und es ist kein Pull Request offen. Offenin progress
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
RT-Thread/rt-thread#11818 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in RT-Thread/rt-thread
Ähnliche Issues
-
Builder: a structure opened without calculation data shows the Diffraction (fibre) view by defaultOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
FriendsofECCE/ECCE#1245 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/nuttx-apps#4108 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
VirtualBox/virtualbox#996 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
trezor/trezor-firmware#8357 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag