|
|
Message-ID: <6ad66968.2a5f2.1a1f243aa54.Coremail.zhaotq@pku.edu.cn>
Date: Thu, 19 Nov 2026 13:24:43 +0800 (GMT+08:00)
From: zhaotq@....edu.cn
To: musl@...ts.openwall.com
Subject: musl libc 1.2.5: PT_TLS p_align=0 causes TLS layout crash
Hello,
We found an availability bug in musl libc's static TLS initialization when an
ELF executable has a PT_TLS program header with p_align equal to zero.
The ELF gABI defines p_align values 0 and 1 as equivalent "no alignment
requirement" encodings. This rule comes from ELF gABI; POSIX does not directly
specify this program-header encoding.
The PoC compiles a normal static musl program, changes the PT_TLS p_align
field to zero, and executes it again. The unmodified binary
runs normally; the modified binary crashes before main().
Relevant musl source:
main_tls.align = tls_phdr->p_align;
main_tls.size += (-main_tls.size - (uintptr_t)main_tls.image)
& (main_tls.align-1);
...
if (main_tls.align < MIN_TLS_ALIGN) main_tls.align = MIN_TLS_ALIGN;
The align-1 mask is used before the zero value is normalized to MIN_TLS_ALIGN.
For p_align=0 the mask is all ones, and the TLS size/layout arithmetic wraps.
The target contains ordinary TLS variables:
static _Thread_local volatile unsigned char tls_one = 0x12;
static _Thread_local volatile unsigned char tls_two = 0x34;
static _Thread_local volatile unsigned char tls_zero;
int main(void)
{
printf("tls_one=%#x tls_two=%#x tls_zero=%#x\n",
tls_one, tls_two, tls_zero);
return !(tls_one == 0x12 && tls_two == 0x34 && tls_zero == 0);
}
Reproduction:
tar xzf 02-tls-p-align-zero.tar.gz
./prepare.sh
cd musl-1.2.5
./poc/linux/run-tls-noalign.sh
Expected marker:
BASELINE_STATUS=0 PATCH_STATUS=0 PATCHED_STATUS=139.
`prepare.sh` downloads the official musl 1.2.5 source from
https://musl.libc.org/releases/musl-1.2.5.tar.gz and verifies this SHA-256:
a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4.
Attached are the PoC archive and README.md, which documents the
environment requirements, reproduction commands, and observed results.
Archive SHA-256:
2236793ef879c29308e973cef4fce483b05f4ed0b7c93702aee87bd151344c25
We would appreciate your assessment of the security impact and whether
a CVE is warranted.
Thanks,
Tianqi
Download attachment "02-tls-p-align-zero.tar.gz" of type "application/x-gzip" (2543 bytes)
Download attachment "README.md" of type "application/octet-stream" (1773 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.