-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
---
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;
--
On Tue, Oct 31, 2006 at 09:34:10PM -0800, Chris Wright wrote:
> -stable review patch. If anyone has any objections, please let us know.
> ------------------
>
> From: NeilBrown <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Chris Wright <[email protected]>
>
> ---
> 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;
This one seems valid for 2.4 too. Neil, do you confirm ?
Willy
Hi Neil,
I don't know if you noticed my request for ACK as I did not get any
response. I think that your patch here is a good candidate for 2.4
too, I would just like to get your confirmation before merging it.
Thanks in advance,
willy
On Wed, Nov 01, 2006 at 08:11:11AM +0100, Willy Tarreau wrote:
On Tue, Oct 31, 2006 at 09:34:10PM -0800, Chris Wright wrote:
> -stable review patch. If anyone has any objections, please let us know.
> ------------------
>
> From: NeilBrown <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Chris Wright <[email protected]>
>
> ---
> 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;
On Saturday November 4, [email protected] wrote:
> Hi Neil,
>
> I don't know if you noticed my request for ACK as I did not get any
> response. I think that your patch here is a good candidate for 2.4
> too, I would just like to get your confirmation before merging it.
Sorry, I went to grab a copy of the latest 2.4 to double-check and the
got distracted.
Yes: this patch is definitely appropriate for 2.4.
Thanks,
NeilBrown
> > ---
> > 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
On Mon, Nov 06, 2006 at 10:55:44AM +1100, Neil Brown wrote:
> On Saturday November 4, [email protected] wrote:
> > Hi Neil,
> >
> > I don't know if you noticed my request for ACK as I did not get any
> > response. I think that your patch here is a good candidate for 2.4
> > too, I would just like to get your confirmation before merging it.
>
> Sorry, I went to grab a copy of the latest 2.4 to double-check and the
> got distracted.
no problem :-)
> Yes: this patch is definitely appropriate for 2.4.
Thanks, I will merge it then.
Cheers,
Willy