Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 24 Sep 2019 11:16:41 +0000
From: changdiankang <changdiankang@...wei.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: [PATCH] time: Fix bug in timer_create

time: Fix bug in timer_create

When create a SIGEV_THREAD timer, in helper thread "start",
"id" is assigned with self->timer_id immediately after pthread_create.
But the real timer_id is assigned to self->timer_id after SYS_timer_create.
So "id" in "start" always be 0, and timer_delete will always fail.
Put assignement of "id" after pthread_barrier_wait can fix this bug.

Signed-off-by: Chang Diankang <changdiankang@...wei.com<mailto:changdiankang@...wei.com>>

diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index c5e40a1..4172b9e 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -48,13 +48,14 @@ static void *start(void *arg)
{
        pthread_t self = __pthread_self();
        struct start_args *args = arg;
-       int id = self->timer_id;
+       int id;
        jmp_buf jb;

        void (*notify)(union sigval) = args->sev->sigev_notify_function;
        union sigval val = args->sev->sigev_value;

        pthread_barrier_wait(&args->b);
+       id = self->timer_id;
        for (;;) {
                siginfo_t si;
                while (sigwaitinfo(SIGTIMER_SET, &si) < 0);


Content of type "text/html" skipped

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.