* [PATCH] knfsd: Fix race that can disable NFS server.
[not found] <20061020114959.26698.patches@notabene>
@ 2006-10-20 1:52 ` NeilBrown
2006-11-05 7:49 ` Adrian Bunk
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2006-10-20 1:52 UTC (permalink / raw)
To: Andrew Morton; +Cc: nfs, linux-kernel, stable, Adrian Bunk
This patch is suitable for just about any 2.6 kernel.
It should go in 2.6.19 and 2.6.18.2 and possible even the .17 and .16
stable series.
### Comments for Changeset
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>
### Diffstat output
./net/sunrpc/svcsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c
--- .prev/net/sunrpc/svcsock.c 2006-10-20 11:49:18.000000000 +1000
+++ ./net/sunrpc/svcsock.c 2006-10-20 11:49:47.000000000 +1000
@@ -1002,7 +1002,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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] knfsd: Fix race that can disable NFS server.
2006-10-20 1:52 ` [PATCH] knfsd: Fix race that can disable NFS server NeilBrown
@ 2006-11-05 7:49 ` Adrian Bunk
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Bunk @ 2006-11-05 7:49 UTC (permalink / raw)
To: NeilBrown; +Cc: Andrew Morton, nfs
On Fri, Oct 20, 2006 at 11:52:44AM +1000, NeilBrown wrote:
> This patch is suitable for just about any 2.6 kernel.
> It should go in 2.6.19 and 2.6.18.2 and possible even the .17 and .16
> stable series.
Thanks, applied to 2.6.16.
> ### Comments for Changeset
>
> 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>
>
> ### Diffstat output
> ./net/sunrpc/svcsock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff .prev/net/sunrpc/svcsock.c ./net/sunrpc/svcsock.c
> --- .prev/net/sunrpc/svcsock.c 2006-10-20 11:49:18.000000000 +1000
> +++ ./net/sunrpc/svcsock.c 2006-10-20 11:49:47.000000000 +1000
> @@ -1002,7 +1002,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;
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-05 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20061020114959.26698.patches@notabene>
2006-10-20 1:52 ` [PATCH] knfsd: Fix race that can disable NFS server NeilBrown
2006-11-05 7:49 ` Adrian Bunk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.