Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <19291579.2a603.1a1f24a0de0.Coremail.zhaotq@pku.edu.cn>
Date: Thu, 19 Nov 2026 13:31:41 +0800 (GMT+08:00)
From: zhaotq@....edu.cn
To: musl@...ts.openwall.com
Subject: musl libc 1.2.5: posix_memalign() crashes for valid extreme
 alignment

Hello,

We found a valid-input crash in musl 1.2.5's allocator. Calling
posix_memalign() with an alignment of 1ULL << 32 and size 1 causes SIGSEGV
before the function returns.

This alignment satisfies POSIX.1-2024 XSH posix_memalign(): the alignment is
a power of two and a multiple of sizeof(void *). POSIX requires successful
allocation with the requested alignment, or an error return, including
[ENOMEM] if sufficient memory is unavailable. A process crash is not one of
the specified failure outcomes.

In musl's mallocng aligned_alloc() path, the aligned pointer can leave a large
padding gap before the end of the allocation. set_size() stores that gap in
an int:

    int reserved = end-p-n;
    if (reserved) end[-reserved] = 0;

For this alignment the padding exceeds INT_MAX, is truncated, and the
reverse-offset write reaches an invalid address.

A reduced PoC is:

    #define _POSIX_C_SOURCE 200809L
    #include <stdlib.h>
    #include <unistd.h>

    int main(void)
    {
        void *p = 0;
        write(2, "before posix_memalign\n", 22);
        if (posix_memalign(&p, (size_t)1 << 32, 1))
            return 77;
        *(volatile unsigned char *)p = 1;
        free(p);
        return 0;
    }

Reproduction:

    tar xzf 04-posix-memalign-extreme-align.tar.gz
    ./prepare.sh
    cd musl-1.2.5
    ./poc/malloc/run-extreme-align.sh

Expected marker:
EXTREME_ALIGN_CRASH=1 signal=11 exit=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:
7364c4cd44fe756fb3fa138509eb53ef29d68373564bd869d259dd1069ae8788

We would appreciate your assessment of the security impact and whether
a CVE is warranted. 

Thanks,
Tianqi

Download attachment "04-posix-memalign-extreme-align.tar.gz" of type "application/x-gzip" (2184 bytes)

Download attachment "README.md" of type "application/octet-stream" (1904 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.