git: 627e7d5b72cf - main - libthr: reject count < 0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 Oct 2026 16:59:30 UTC
The branch main has been updated by aokblast:
URL: https://cgit.FreeBSD.org/src/commit/?id=627e7d5b72cf967eae3cd9e9e0707ce0ff63a4da
commit 627e7d5b72cf967eae3cd9e9e0707ce0ff63a4da
Author: ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-10-07 01:30:56 +0000
Commit: ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2026-10-07 16:59:19 +0000
libthr: reject count < 0
This causes count == -1 spin for INT_MAX times in userspace.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60425
---
lib/libthr/thread/thr_mutex.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 1787db825bf3..ccb3094db16d 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -1109,6 +1109,8 @@ __pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count)
struct pthread_mutex *m;
int ret;
+ if (count < 0)
+ return (EINVAL);
ret = check_and_init_mutex(mutex, &m);
if (ret == 0)
m->m_spinloops = count;
@@ -1133,6 +1135,8 @@ __pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count)
struct pthread_mutex *m;
int ret;
+ if (count < 0)
+ return (EINVAL);
ret = check_and_init_mutex(mutex, &m);
if (ret == 0)
m->m_yieldloops = count;