[Bug] musl __pthread_exit thread-list use-after-free under concurrent thread exit (RT-Thread Smart, SMP)

Open
#11,932 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c

Research direction

Read the attached report and inspect musl's __tl_lock/__tl_sync synchronization and thread-list unlinking in __pthread_exit. Reproduce with the attached tl_race.c command (./tl_race 1000 8) on RT-Thread Smart with SMP and AArch64, then trace the lock behavior during concurrent exits. Done means concurrent create/exit no longer corrupts the thread list or crashes.

Written by the indexing model from the issue text.

Description

Arch: ARM/AArch64 bug RT-Smart
RT-Thread Version

5.2.2

Affected area

RT-Smart

Hardware/BSP vendor

Not applicable / Other

Architecture

ARM / AArch64

Board and hardware details

N/A

Develop Toolchain

GCC

Describe the bug

Concurrent pthread_create/exit crashes user processes on RT-Thread Smart 5.2.2 (SMP, aarch64, musl 1.2.5) inside musl_pthread_exit:
thread-list unlink writes to a thread descriptor already freed/unmapped (Data Abort), or a thread's return address is corrupted to 0 (Instruction Abort). Root cause: the futex-based __tl_lock/__tl_sync fails to provide mutual exclusion for musl's thread-list under concurrent exit on SMP, corrupting the doubly-linked list – entirely user-space, kernel futex is structurally correct.
(tl_race.c, attached): ./tl_race 1000 8 crashes after a few hundred rounds. Details in the attached report.

musl pthread_exit thread-list UAF.md

Other additional context

No response

Dominant language
C
Stars
12.4k
Forks
5.5k
Avg merge
3d 7h
Merged PRs (30d)
79

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RT-Thread/rt-thread

All issues in RT-Thread/rt-thread

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.