git: 8331d5a2fe96 - main - pthread_cond_clockwait(3): explicitly reject unacceptable clockids
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Nov 2026 00:22:07 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=8331d5a2fe967016343fb4322f1ed73e55ff9655
commit 8331d5a2fe967016343fb4322f1ed73e55ff9655
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-05 21:38:37 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-10 00:21:18 +0000
pthread_cond_clockwait(3): explicitly reject unacceptable clockids
Otherwise they are rejected by kernel in do_wait(), reached through
_thr_sleep()/UMTX_OP_WAIT_UINT_PRIVATE on the user-mode path. Then,
since cond_wait_user() only leaves its loop on a wakeup, a cancellation
or ETIMEDOUT, the EINVAL from do_wait() results in a loop.
If hit, this indicates a bug in user code, but the system library
must be resilient to such misuse.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61253
---
lib/libthr/thread/thr_cond.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/libthr/thread/thr_cond.c b/lib/libthr/thread/thr_cond.c
index cce2ba7b6c3c..c2ce9565e208 100644
--- a/lib/libthr/thread/thr_cond.c
+++ b/lib/libthr/thread/thr_cond.c
@@ -442,6 +442,8 @@ __pthread_cond_clockwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
abstime->tv_nsec >= 1000000000)
return (EINVAL);
+ if (_thr_check_clockid(clockid) != 0)
+ return (EINVAL);
return (cond_wait_common(cond, mutex, clockid, abstime, true, true));
}