From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941023AbXGaEav (ORCPT ); Tue, 31 Jul 2007 00:30:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759708AbXGaE3q (ORCPT ); Tue, 31 Jul 2007 00:29:46 -0400 Received: from canuck.infradead.org ([209.217.80.40]:42245 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S940778AbXGaE3p (ORCPT ); Tue, 31 Jul 2007 00:29:45 -0400 Date: Mon, 30 Jul 2007 21:31:24 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, kuznet@ms2.inr.ac.ru, mingo@elte.hu, Thomas Gleixner , Chris Wright , Greg Kroah-Hartman Subject: [patch 03/26] rt-mutex: Fix stale return value Message-ID: <20070731043124.GD3975@kroah.com> References: <20070731042108.546594256@blue.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="rt-mutex-fix-stale-return-value.patch" In-Reply-To: <20070731043047.GA3975@kroah.com> User-Agent: Mutt/1.5.15 (2007-04-06) X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org -stable review patch. If anyone has any objections, please let us know. ------------------ 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 file changed, 9 insertions(+), 2 deletions(-) --- linux-2.6.21.6.orig/kernel/rtmutex.c +++ linux-2.6.21.6/kernel/rtmutex.c @@ -659,9 +659,16 @@ rt_mutex_slowlock(struct rt_mutex *lock, * 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; } --