nuttx/sched/misc
chenzhaoxiang 635f64ebb8 sched/misc: fix potential out-of-bounds access in coredump stack emission
The elf_emit_tcb_stack() function in coredump.c was calculating the stackbuffer length
and emitting the stack data without validating whether thecalculated buffer range
(buf + len) exceeds the actual bounds of the TCB'sstack memory region (stack_base_ptr + adj_stack_size).

This could lead to out-of-bounds memory access when the calculated stacklength is larger
than the available stack space, potentially causing memorycorruption, crashes, or incorrect
core dump generation.

This fix adds a bounds check:
1. Compares the end of the intended stack buffer (buf + len) against the
   upper limit of the TCB's stack (stack_base_ptr + adj_stack_size).
2. If the buffer would exceed the stack bounds, truncates the length to fit
   within the valid stack memory range.

The change ensures safe memory access during core dump generation,preventing out-of-bounds
reads and improving the robustness of the coredumpfeature.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-02-27 17:52:34 +08:00
..
assert.c sched/misc: fix incorrect mutex holder retrieval in assert backtrace 2026-02-27 09:24:55 +08:00
CMakeLists.txt coredump:Move coredump to sched/misc 2024-10-12 12:29:06 +08:00
coredump.c sched/misc: fix potential out-of-bounds access in coredump stack emission 2026-02-27 17:52:34 +08:00
coredump.h coredump:Move private functions to internal header files 2024-10-12 12:29:06 +08:00
deadlock.c Clean up the nxmutex library 2025-05-08 16:00:05 +08:00
Make.defs coredump:Move coredump to sched/misc 2024-10-12 12:29:06 +08:00
panic_notifier.c spinlock: Fix compilation error with atomic.h. 2025-06-25 22:13:00 +08:00
reboot_notifier.c userspace: Exclude nuttx/arch.h 2024-11-01 16:59:37 +08:00