[BUG 2.5.57] NFSv2 READDIR broken

From: Jochen Friedrich (jochen@scram.de)
Date: Mon Jan 13 2003 - 15:27:23 EST


Hi,

if mounting a Linux partition with NFSv2, READDIR fills in the last cookie
byte-swapped. The following READDIR will fail, so the NFS client sees a
truncated directory:

Frame 43 (1074 bytes on wire, 1074 bytes captured)
Ethernet II, Src: 00:00:e8:d4:01:61, Dst: 00:60:b3:1f:52:7c
Internet Protocol, Src Addr: 192.168.94.2 (192.168.94.2), Dst Addr: 192.168.95.4 (192.168.95.4)
User Datagram Protocol, Src Port: 2049 (2049), Dst Port: 800 (800)
Remote Procedure Call
Network File System
    Program Version: 2
    V2 Procedure: READDIR (16)
    Status: OK (0)
    Value Follows: Yes
    Entry: file ID 1274231, name .
        File ID: 1274231
        Name: .
            length: 1
            contents: .
            fill bytes: opaque data
        Cookie: 12
    Value Follows: Yes
[...]
    Entry: file ID 1274709, name LICENSE.SRC
        File ID: 1274709
        Name: LICENSE.SRC
            length: 11
            contents: LICENSE.SRC
            fill bytes: opaque data
        Cookie: 644
    Value Follows: Yes
    Entry: file ID 1275342, name Makefile
        File ID: 1275342
        Name: Makefile
            length: 8
            contents: Makefile
        Cookie: 2483159040 <<<<<<<<<<< should be 678
    Value Follows: No
    EOF: 0

This patch corrects the problem:

===== nfsproc.c 1.23 vs edited =====
--- 1.23/fs/nfsd/nfsproc.c Sat Jan 11 02:00:12 2003
+++ edited/nfsproc.c Mon Jan 13 21:03:28 2003
@@ -482,7 +482,7 @@

  resp->count = resp->buffer - argp->buffer;
  if (resp->offset)
- *resp->offset = (u32)offset;
+ *resp->offset = htonl(offset);

  fh_put(&argp->fh);
  return nfserr;

--jochen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:47 EST