From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44159 invoked by alias); 13 Apr 2016 19:46:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 44150 invoked by uid 89); 13 Apr 2016 19:46:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Delay, pthread_mutex_t, 265,6, 2656 X-HELO: Galois.linutronix.de From: Sebastian Andrzej Siewior To: libc-alpha@sourceware.org Cc: carlos@redhat.com, Sebastian Andrzej Siewior Subject: [PATCH][BZ 19944] nptl/pthread_mutex*lock: don't ignore unknown error codes Date: Wed, 13 Apr 2016 19:46:00 -0000 Message-Id: <1460576781-12017-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 X-SW-Source: 2016-04/txt/msg00331.txt.bz2 pthread_mutex_lock(), pthread_mutex_trylock() and pthread_mutex_unlock() ignore the return code from the futex syscall unless it is something the function expects. This patch forwards the error code to the user instead of simply ignoring it. 2016-04-13 Sebastian Andrzej Siewior [BZ #19944] * nptl/pthread_mutex_lock.c: return unhandled sys_futex error. * nptl/pthread_mutex_trylock.c: return unhandled sys_futex error. * nptl/pthread_mutex_unlock.c: return unhandled sys_futex error. --- nptl/pthread_mutex_lock.c | 3 ++- nptl/pthread_mutex_trylock.c | 2 ++ nptl/pthread_mutex_unlock.c | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index bdfa529f639b..f1b9aa1b9f84 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -354,7 +354,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) /* Delay the thread indefinitely. */ while (1) pause_not_cancel (); - } + } else if (INTERNAL_SYSCALL_ERROR_P (e, __err)) + return INTERNAL_SYSCALL_ERRNO (e, __err); oldval = mutex->__data.__lock; diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 48c7865702ba..45c416b75cf2 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -265,6 +265,8 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex) THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); return EBUSY; + } else if (INTERNAL_SYSCALL_ERROR_P (e, __err)) { + return INTERNAL_SYSCALL_ERRNO (e, __err); } oldval = mutex->__data.__lock; diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 334ce383420e..787fb3017c44 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -243,8 +243,11 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr) tid))) { INTERNAL_SYSCALL_DECL (__err); - INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock, + int e = INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock, __lll_private_flag (FUTEX_UNLOCK_PI, private)); + + if (INTERNAL_SYSCALL_ERROR_P (e, __err)) + return INTERNAL_SYSCALL_ERRNO (e, __err); } THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); -- 2.8.0.rc3