Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946539AbWKAFo1 (ORCPT ); Wed, 1 Nov 2006 00:44:27 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1946545AbWKAFn6 (ORCPT ); Wed, 1 Nov 2006 00:43:58 -0500 Received: from 216-99-217-87.dsl.aracnet.com ([216.99.217.87]:62683 "EHLO sous-sol.org") by vger.kernel.org with ESMTP id S1946537AbWKAFm7 (ORCPT ); Wed, 1 Nov 2006 00:42:59 -0500 Message-Id: <20061101054028.568862000@sous-sol.org> References: <20061101053340.305569000@sous-sol.org> User-Agent: quilt/0.45-1 Date: Tue, 31 Oct 2006 21:34:10 -0800 From: Chris Wright To: linux-kernel@vger.kernel.org, stable@kernel.org, Andrew Morton Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , torvalds@osdl.org, alan@lxorguk.ukuu.org.uk, NeilBrown , Adrian Bunk , nfs@lists.sourceforge.net, Greg Kroah-Hartman Subject: [PATCH 30/61] knfsd: Fix race that can disable NFS server. Content-Disposition: inline; filename=knfsd-fix-race-that-can-disable-nfs-server.patch Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1924 Lines: 53 -stable review patch. If anyone has any objections, please let us know. ------------------ From: NeilBrown This is a long standing bug that seems to have only recently become apparent, presumably due to increasing use of NFS over TCP - many distros seem to be making it the default. The SK_CONN bit gets set when a listening socket may be ready for an accept, just as SK_DATA is set when data may be available. It is entirely possible for svc_tcp_accept to be called with neither of these set. It doesn't happen often but there is a small race in svc_sock_enqueue as SK_CONN and SK_DATA are tested outside the spin_lock. They could be cleared immediately after the test and before the lock is gained. This normally shouldn't be a problem. The sockets are non-blocking so trying to read() or accept() when ther is nothing to do is not a problem. However: svc_tcp_recvfrom makes the decision "Should I accept() or should I read()" based on whether SK_CONN is set or not. This usually works but is not safe. The decision should be based on whether it is a TCP_LISTEN socket or a TCP_CONNECTED socket. Signed-off-by: Neil Brown Signed-off-by: Greg Kroah-Hartman Signed-off-by: Chris Wright --- net/sunrpc/svcsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- linux-2.6.18.1.orig/net/sunrpc/svcsock.c +++ linux-2.6.18.1/net/sunrpc/svcsock.c @@ -902,7 +902,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) return 0; } - if (test_bit(SK_CONN, &svsk->sk_flags)) { + if (svsk->sk_sk->sk_state == TCP_LISTEN) { svc_tcp_accept(svsk); svc_sock_received(svsk); return 0; -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/