Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20261129150405.GD5716@brightrain.aerifal.cx>
Date: Sun, 29 Nov 2026 10:04:05 -0500
From: Rich Felker <dalias@...c.org>
To: 吴尚哲 <wushangzhe26@....pku.edu.cn>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: Bug in ualarm(): reads uninitialized timer data after
 setitimer() fails

On Thu, Nov 26, 2026 at 05:55:53PM +0800, 吴尚哲 wrote:
> Hello,
> ualarm() in musl 1.2.5 copies the requested duration directly
> into tv_usec and leaves tv_sec at zero. Linux expects tv_usec
> to hold only the subsecond remainder, so setitimer() rejects
> an out-of-range value with EINVAL.
> 
> 
> In src/unistd/ualarm.c:11–12:
>     setitimer(ITIMER_REAL, &it, &it_old);
>     return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
> 
> 
> ualarm() ignores the error and computes its return value from
> it_old, which is uninitialized when setitimer() leaves it untouched.
> 
> 
> In our static x86_64 tests, the failing setitimer() call left the
> sentinel bytes in its output structure unchanged. In the
> corresponding ualarm() test, the return value changed when we filled
> it_old with a known byte pattern.
> 
> 
> Checking the result of setitimer() and returning an error before
> reading it_old would fix the uninitialized read.

Unfortunately ualarm has no specified contract for returning an error.
I'm not sure what the best way to handle it is. Maybe we can normalize
the time?

Rich

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.