]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
[PATCH] knfsd: Fix race that can disable NFS server.
authorNeilBrown <neilb@suse.de>
Fri, 20 Oct 2006 01:52:44 +0000 (11:52 +1000)
committerChris Wright <chrisw@sous-sol.org>
Sat, 4 Nov 2006 01:33:47 +0000 (17:33 -0800)
commit02bb8f3f912d8a2048ed7502a733f64c6bf8fcfe
tree9f164d0e41380c9ed42849c6639bf9c2b4bb3d6d
parent8fb3dd17ba82cf264224fc19c69efb42e4370f28
[PATCH] knfsd: Fix race that can disable NFS server.

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 <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
net/sunrpc/svcsock.c