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
This commit is contained in:
ShengYi Hung committed 2026-10-08 03:59:19 +11:00
1 parent 1d21e67e72
commit 627e7d5b72
1 file changed
+4
+4
View File
@@ -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;