git: b4c8ab2b7a84 - stable/15 - pthread_mutex_timedlock(3): return EDEADLK on detected recursion attempt

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 01:09:46 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=b4c8ab2b7a84b6705a4f2adaccdbad5f45f1abc3

commit b4c8ab2b7a84b6705a4f2adaccdbad5f45f1abc3
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-05 22:01:18 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-17 00:25:01 +0000

    pthread_mutex_timedlock(3): return EDEADLK on detected recursion attempt
    
    (cherry picked from commit bf2939ea60872d7791987d1727798e90eb904279)
---
 lib/libthr/thread/thr_mutex.c            | 22 +++++-----------------
 share/man/man3/pthread_mutex_timedlock.3 |  2 +-
 2 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index cd79a5d1e93d..e1e790aa43bf 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -897,23 +897,11 @@ mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime)
 	switch (PMUTEX_TYPE(m->m_flags)) {
 	case PTHREAD_MUTEX_ERRORCHECK:
 	case PTHREAD_MUTEX_ADAPTIVE_NP:
-		if (abstime) {
-			if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
-			    abstime->tv_nsec >= 1000000000) {
-				ret = EINVAL;
-			} else {
-				clock_gettime(CLOCK_REALTIME, &ts1);
-				TIMESPEC_SUB(&ts2, abstime, &ts1);
-				__sys_nanosleep(&ts2, NULL);
-				ret = ETIMEDOUT;
-			}
-		} else {
-			/*
-			 * POSIX specifies that mutexes should return
-			 * EDEADLK if a recursive lock is detected.
-			 */
-			ret = EDEADLK; 
-		}
+		/*
+		 * POSIX specifies that mutexes should return EDEADLK
+		 * if a recursive lock is detected.
+		 */
+		ret = EDEADLK;
 		break;
 
 	case PTHREAD_MUTEX_NORMAL:
diff --git a/share/man/man3/pthread_mutex_timedlock.3 b/share/man/man3/pthread_mutex_timedlock.3
index b6e95edbe46e..793f975e286e 100644
--- a/share/man/man3/pthread_mutex_timedlock.3
+++ b/share/man/man3/pthread_mutex_timedlock.3
@@ -85,7 +85,7 @@ maximum number of recursive locks for the
 .Fa mutex
 has been exceeded.
 .It Bq Er EDEADLK
-The current thread already owns the
+The current thread already owns the error-checking
 .Fa mutex .
 .It Bq Er EOWNERDEAD
 The argument