Skip to content

Commit f67b55b

Browse files
bcodding-rhamschuma-ntap
authored andcommitted
NFS: Guard against READDIR loop when entry names exceed MAXNAMELEN
Commit 64cfca8 asserts the only valid return values for nfs2/3_decode_dirent should not include -ENAMETOOLONG, but for a server that sends a filename3 which exceeds MAXNAMELEN in a READDIR response the client's behavior will be to endlessly retry the operation. We could map -ENAMETOOLONG into -EBADCOOKIE, but that would produce truncated listings without any error. The client should return an error for this case to clearly assert that the server implementation must be corrected. Fixes: 64cfca8 ("NFS: Return valid errors from nfs2/3_decode_dirent()") Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 51d674a commit f67b55b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/nfs/nfs2xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
949949

950950
error = decode_filename_inline(xdr, &entry->name, &entry->len);
951951
if (unlikely(error))
952-
return -EAGAIN;
952+
return error == -ENAMETOOLONG ? -ENAMETOOLONG : -EAGAIN;
953953

954954
/*
955955
* The type (size and byte order) of nfscookie isn't defined in

fs/nfs/nfs3xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
19911991

19921992
error = decode_inline_filename3(xdr, &entry->name, &entry->len);
19931993
if (unlikely(error))
1994-
return -EAGAIN;
1994+
return error == -ENAMETOOLONG ? -ENAMETOOLONG : -EAGAIN;
19951995

19961996
error = decode_cookie3(xdr, &new_cookie);
19971997
if (unlikely(error))

0 commit comments

Comments
 (0)