From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756131AbYHRTcb (ORCPT ); Mon, 18 Aug 2008 15:32:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757863AbYHRTbg (ORCPT ); Mon, 18 Aug 2008 15:31:36 -0400 Received: from ns1.suse.de ([195.135.220.2]:48205 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933229AbYHRTbe (ORCPT ); Mon, 18 Aug 2008 15:31:34 -0400 Date: Mon, 18 Aug 2008 12:19:53 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org, jejb@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Sven Wegener , Simon Horman Subject: [patch 17/49] ipvs: Fix possible deadlock in estimator code Message-ID: <20080818191953.GR10350@suse.de> References: <20080818191012.663450219@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="ipvs-fix-possible-deadlock-in-estimator-code.patch" In-Reply-To: <20080818191834.GA10350@suse.de> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2.6.25-stable review patch. If anyone has any objections, please let us know. ------------------ From: Sven Wegener commit 8ab19ea36c5c5340ff598e4d15fc084eb65671dc upstream There is a slight chance for a deadlock in the estimator code. We can't call del_timer_sync() while holding our lock, as the timer might be active and spinning for the lock on another cpu. Work around this issue by using try_to_del_timer_sync() and releasing the lock. We could actually delete the timer outside of our lock, as the add and kill functions are only every called from userspace via [gs]etsockopt() and are serialized by a mutex, but better make this explicit. Signed-off-by: Sven Wegener Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ipvs/ip_vs_est.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c @@ -172,8 +172,11 @@ void ip_vs_kill_estimator(struct ip_vs_s kfree(est); killed++; } - if (killed && est_list == NULL) - del_timer_sync(&est_timer); + while (killed && !est_list && try_to_del_timer_sync(&est_timer) < 0) { + write_unlock_bh(&est_lock); + cpu_relax(); + write_lock_bh(&est_lock); + } write_unlock_bh(&est_lock); } --