All of lore.kernel.org
 help / color / mirror / Atom feed
* Should truncated READDIR replies return -EIO?
@ 2008-02-08 15:04 Jeff Layton
  2008-02-08 15:13 ` Trond Myklebust
  0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2008-02-08 15:04 UTC (permalink / raw)
  To: linux-nfs

Recently, I ran across a server-side bug that caused the server to send
truncated READDIR replies. The server would send a valid RPC response to
a READDIR call, but the contents of it were basically missing
(everything after the status).

The server problem had long been patched in mainline kernels, but the
interesting bit was that clients didn't return an error in this
situation. The XDR decoders for readdir calls are supposed to check the
validity of the response, but in this situation it just fudges the
contents of the pagecache to make it look like a completely empty
directory.

Shouldn't the client return an error in this situation? The response
obviously isn't valid so it seems like it shouldn't pretend that it is.
If so, would something like the following patch make sense?

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/nfs/nfs2xdr.c |    1 +
 fs/nfs/nfs3xdr.c |    1 +
 fs/nfs/nfs4xdr.c |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 1f7ea67..aa6966a 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -478,6 +478,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
 	if (!nr) {
 		dprintk("NFS: readdir reply truncated!\n");
 		entry[1] = 1;
+		nr = -errno_NFSERR_IO;
 	}
 	goto out;
 err_unmap:
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 3917e2f..04ba525 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -592,6 +592,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
 	if (!nr) {
 		dprintk("NFS: readdir reply truncated!\n");
 		entry[1] = 1;
+		nr = -errno_NFSERR_IO;
 	}
 	goto out;
 err_unmap:
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index db1ed9c..139c9e1 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -3544,6 +3544,7 @@ short_pkt:
 	if (!nr) {
 		dprintk("NFS: readdir reply truncated!\n");
 		entry[1] = 1;
+		nr = -errno_NFSERR_IO;
 	}
 	goto out;
 err_unmap:
-- 
1.5.3.8


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-02-19 16:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-08 15:04 Should truncated READDIR replies return -EIO? Jeff Layton
2008-02-08 15:13 ` Trond Myklebust
     [not found]   ` <1202483596.8914.13.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-02-08 15:18     ` Trond Myklebust
     [not found]       ` <1202483883.10337.2.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-02-08 15:42         ` Peter Staubach
2008-02-08 15:39     ` Peter Staubach
2008-02-08 16:18       ` Jeff Layton
2008-02-08 17:16       ` Chuck Lever
2008-02-08 18:16         ` Peter Staubach
2008-02-08 19:25           ` Chuck Lever
2008-02-08 15:56     ` Jeff Layton
     [not found]       ` <20080208105659.3bfb8a6b-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-02-08 16:13         ` Trond Myklebust
     [not found]           ` <1202487187.10337.25.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-02-08 16:51             ` Jeff Layton
2008-02-12 13:20             ` Jeff Layton
     [not found]               ` <20080212082038.7e75670e-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-02-13  0:13                 ` Trond Myklebust
     [not found]                   ` <1202861583.14707.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-02-19 16:49                     ` Jeff Layton

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.