From: GNU Libc Maintainers Date: Mon, 25 Aug 2025 19:11:05 +0000 (+0200) Subject: git-sem_wait_race X-Git-Tag: archive/raspbian/2.36-9+rpi1+deb12u13^2~67 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b0bbce677ac08b1311f94cd6319661037f54f4f1;p=glibc.git git-sem_wait_race commit 289b098c9e21e2805e3835f9b5780235ab14a290 Author: Samuel Thibault Date: Fri Dec 30 00:40:18 2022 +0100 htl: Fix sem_wait race between read and gsync_wait If the value changes between sem_wait's read and the gsync_wait call, the kernel will return KERN_INVALID_ARGUMENT, which we have to interpret as the value having already changed. This fixes applications (e.g. libgo) seeing sem_wait erroneously return KERN_INVALID_ARGUMENT. Gbp-Pq: Topic hurd-i386 Gbp-Pq: Name git-sem_wait_race.diff --- diff --git a/sysdeps/htl/sem-timedwait.c b/sysdeps/htl/sem-timedwait.c index 1b1eec9f5..c610804b0 100644 --- a/sysdeps/htl/sem-timedwait.c +++ b/sysdeps/htl/sem-timedwait.c @@ -79,7 +79,7 @@ __sem_timedwait_internal (sem_t *restrict sem, ((unsigned int *) &sem->data) + SEM_VALUE_OFFSET, 0, flags); - if (err != 0) + if (err != 0 && err != KERN_INVALID_ARGUMENT) { /* Error, interruption or timeout, abort. */ if (err == KERN_TIMEDOUT) @@ -138,7 +138,7 @@ __sem_timedwait_internal (sem_t *restrict sem, err = __lll_wait_intr (&isem->value, SEM_NWAITERS_MASK, flags); - if (err != 0) + if (err != 0 && err != KERN_INVALID_ARGUMENT) { /* Error, interruption or timeout, abort. */ if (err == KERN_TIMEDOUT)