|
|
Message-ID: <20261203230538.GL5716@brightrain.aerifal.cx>
Date: Thu, 3 Dec 2026 18:05:38 -0500
From: Rich Felker <dalias@...c.org>
To: Joel Baptista <jdbaptista@...me>
Cc: musl@...ts.openwall.com
Subject: Re: Re: Bug in ualarm(): reads uninitialized timer data after
setitimer() fails
On Thu, Dec 03, 2026 at 10:29:15PM +0000, Joel Baptista wrote:
> On Sun, Nov 29, 2026 at 02:30:33PM -0500, Rich Felker wrote:
> > Does the attached look ok?
>
> Yes. I applied it to master (7813e911), built a static libc, and
> tested it on x86_64 with this program:
>
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <unistd.h>
>
> int main(void)
> {
> ualarm(2500000, 3200000);
> printf("%u\n", ualarm(0, 0));
> return 0;
> }
>
> Without the patch it prints 0, because the first call fails with
> EINVAL and the timer is never armed. With the patch it prints
> 2499998.
>
> I also checked with getitimer that the interval is set to 3.200000,
> and that the values 999999, 1000000, 1000001 and 4294967295 all arm
> the timer without error.
>
> You mentioned a separate patch for the case where setitimer fails.
> Let me know if you plan to write it; otherwise I can take care of it.
Writing it is nbd, but we should figure out what it should return that
doesn't violate caller expectations. It can't return an actual -1
because the return value is unsigned. It could return -1 coerced to
unsigned (UINT_MAX), or it could return 0 presuming the syscall is
blocked and this means there can't be any alarm armed (but that may be
incorrect if seccomp was armed after the alarm?).
I don't think it's urgent to do anything here and I'd like to make
sure whatever we do is intentional and well-justified before doing
rather than spring a later change on users.
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.