Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/nfs Pull up revision 1.219 (requested by yamt in ti...



details:   https://anonhg.NetBSD.org/src/rev/7cbf3de5f422
branches:  netbsd-2-0
changeset: 564698:7cbf3de5f422
user:      tron <tron%NetBSD.org@localhost>
date:      Wed Mar 16 12:50:30 2005 +0000

description:
Pull up revision 1.219 (requested by yamt in ticket #1208):
nfs_readdirrpc, nfs_readdirplusrpc:
avoid infinite loops when getting readdir response without
any entries or eof.  PR/28971.

diffstat:

 sys/nfs/nfs_vnops.c |  26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diffs (68 lines):

diff -r 7a4e0e25d811 -r 7cbf3de5f422 sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c       Wed Mar 16 12:48:12 2005 +0000
+++ b/sys/nfs/nfs_vnops.c       Wed Mar 16 12:50:30 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_vnops.c,v 1.186.2.9 2005/03/16 12:09:47 tron Exp $ */
+/*     $NetBSD: nfs_vnops.c,v 1.186.2.10 2005/03/16 12:50:30 tron Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.186.2.9 2005/03/16 12:09:47 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.186.2.10 2005/03/16 12:50:30 tron Exp $");
 
 #include "opt_nfs.h"
 #include "opt_uvmhist.h"
@@ -2426,7 +2426,7 @@
         * Should be called from buffer cache, so only amount of
         * NFS_DIRBLKSIZ will be requested.
         */
-       if (uiop->uio_iovcnt != 1 || (uiop->uio_resid & (NFS_DIRBLKSIZ - 1)))
+       if (uiop->uio_iovcnt != 1 || uiop->uio_resid != NFS_DIRBLKSIZ)
                panic("nfs readdirrpc bad uio");
 #endif
 
@@ -2575,6 +2575,17 @@
                if (!more_dirs) {
                        nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
                        more_dirs = (fxdr_unsigned(int, *tl) == 0);
+
+                       /*
+                        * kludge: if we got no entries, treat it as EOF.
+                        * some server sometimes send a reply without any
+                        * entries or EOF.
+                        * although it might mean the server has very long name,
+                        * we can't handle such entries anyway.
+                        */
+
+                       if (uiop->uio_resid >= NFS_DIRBLKSIZ)
+                               more_dirs = 0;
                }
                m_freem(mrep);
        }
@@ -2630,7 +2641,7 @@
        struct nfs_fattr fattr, *fp;
 
 #ifdef DIAGNOSTIC
-       if (uiop->uio_iovcnt != 1 || (uiop->uio_resid & (NFS_DIRBLKSIZ - 1)))
+       if (uiop->uio_iovcnt != 1 || uiop->uio_resid != NFS_DIRBLKSIZ)
                panic("nfs readdirplusrpc bad uio");
 #endif
        ndp->ni_dvp = vp;
@@ -2805,6 +2816,13 @@
                if (!more_dirs) {
                        nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
                        more_dirs = (fxdr_unsigned(int, *tl) == 0);
+
+                       /*
+                        * kludge: see a comment in nfs_readdirrpc.
+                        */
+
+                       if (uiop->uio_resid >= NFS_DIRBLKSIZ)
+                               more_dirs = 0;
                }
                m_freem(mrep);
        }



Home | Main Index | Thread Index | Old Index