]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: task: Do not destroy a task that is not ours in task_destroy
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 9 Apr 2026 13:37:14 +0000 (15:37 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 18 Sep 2026 12:37:12 +0000 (14:37 +0200)
In task_destroy(), if the task is not exclusively ours, then just use
task_kill(). If it is a shared task, then there is a race condition if
another thread tries to schedule it at the same time, which could result
in the task being scheduled after been freed.

This should be backported up to 2.8.

include/haproxy/task.h

index 2a70cdcfd36f12fe4af3ff0c099b8deb9c644035..403c36d2c2b87b0343804727e52afbac0333d9e8 100644 (file)
@@ -775,6 +775,11 @@ static inline void task_destroy(struct task *t)
        if (!t)
                return;
 
+       if (t->tid != tid) {
+               task_kill(t);
+               return;
+       }
+
        task_unlink_wq(t);
        /* We don't have to explicitly remove from the run queue.
         * If we are in the runqueue, the test below will set t->process