{19486} arch/arm: set PSPLIM to top of TLS region to protect it from overflow - #19634
Merged
Merged
Conversation
A crash was observed when running ps: a BusFault in nxtask_argvstr dereferencing tl_argv, because a thread's stack overflow had silently corrupted the TLS region where tl_argv resides. On ARMv8-M with CONFIG_ARMV8M_STACKCHECK_HARDWARE, PSPLIM was set to stack_alloc_ptr -- the bottom of the allocation where TLS begins. The stack grows downward and TLS occupies [stack_alloc_ptr, stack_alloc_ptr + tls_info_size()), so an overflow crossed into TLS and clobbered tl_argv before SP reached the limit, going undetected until code that read the corrupted TLS data (such as ps) hit the bad pointer. Set the limit to stack_alloc_ptr + tls_info_size() -- the top of the TLS region and the usable stack base -- so an overflow faults at the TLS boundary, before any TLS byte is touched. Include <tls/tls.h> for the tls_info_size() macro, which is the value sched reserves for the TLS region via up_stack_frame(). Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
jerpelea
requested review from
acassis,
cederom,
linguini1,
lupyuen and
xiaoxiang781216
August 3, 2026 09:55
cederom
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A crash was observed when running ps: a BusFault in nxtask_argvstr dereferencing tl_argv, because a thread's stack overflow had silently corrupted the TLS region where tl_argv resides.
On ARMv8-M with CONFIG_ARMV8M_STACKCHECK_HARDWARE, PSPLIM was set to stack_alloc_ptr -- the bottom of the allocation where TLS begins. The stack grows downward and TLS occupies [stack_alloc_ptr, stack_alloc_ptr
Set the limit to stack_alloc_ptr + tls_info_size() -- the top of the TLS region and the usable stack base -- so an overflow faults at the TLS boundary, before any TLS byte is touched. Include <tls/tls.h> for the tls_info_size() macro, which is the value sched reserves for the TLS region via up_stack_frame().
Impact
RELEASE
Testing
CI