From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932300AbXHKTIA (ORCPT ); Sat, 11 Aug 2007 15:08:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1763155AbXHKS7c (ORCPT ); Sat, 11 Aug 2007 14:59:32 -0400 Received: from 1wt.eu ([62.212.114.60]:1614 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762475AbXHKS7a (ORCPT ); Sat, 11 Aug 2007 14:59:30 -0400 From: Willy Tarreau Message-Id: <20070811184839.%N@1wt.eu> References: <20070811184752.%N@1wt.eu> User-Agent: quilt/0.46-1 Date: Sat, 11 Aug 2007 21:48:02 +0200 To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Alexey Kuznetsov , Thomas Gleixner , Ingo Molnar , Chris Wright , Greg Kroah-Hartman Subject: [2.6.20.16 review 10/28] rt-mutex: Fix stale return value Content-Disposition: inline; filename=0010-rt-mutex-Fix-stale-return-value.patch Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Alexey Kuznetsov found some problems in the pi-futex code. The major problem is a stale return value in rt_mutex_slowlock(): When the pi chain walk returns -EDEADLK, but the waiter was woken up during the phases where the locks were dropped, the rtmutex could be acquired, but due to the stale return value -EDEADLK returned to the caller. Reset the return value in the woken up path. Cc: Alexey Kuznetsov Signed-off-by: Thomas Gleixner Acked-by: Ingo Molnar Signed-off-by: Chris Wright Signed-off-by: Greg Kroah-Hartman --- kernel/rtmutex.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c index 4ab17da..9b08847 100644 --- a/kernel/rtmutex.c +++ b/kernel/rtmutex.c @@ -659,9 +659,16 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, * all over without going into schedule to try * to get the lock now: */ - if (unlikely(!waiter.task)) + if (unlikely(!waiter.task)) { + /* + * Reset the return value. We might + * have returned with -EDEADLK and the + * owner released the lock while we + * were walking the pi chain. + */ + ret = 0; continue; - + } if (unlikely(ret)) break; } -- 1.5.2.4 --