When the procfs root directory is listed using more than one getdents()
call, the process iterator can mistakenly skip a few processes. The
patch corrects this by making the index of the first process entry match
with the static procfs entries. This prevents over-winding of the
process list during subsequent getdents() calls.

Index: sys/miscfs/procfs/procfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/miscfs/procfs/procfs_vnops.c,v
retrieving revision 1.60
diff -N -u -p sys/miscfs/procfs/procfs_vnops.c
--- sys/miscfs/procfs/procfs_vnops.c    8 Jul 2014 17:19:25 -0000       1.60
+++ sys/miscfs/procfs/procfs_vnops.c    19 Aug 2014 13:54:11 -0000
@@ -853,11 +853,15 @@ procfs_readdir(void *v)
 #ifdef PROCFS_ZOMBIE
                int doingzomb = 0;
 #endif
+               int firstproc;
                int pcnt = i;
                volatile struct process *pr = LIST_FIRST(&allprocess);
 
-               if (pcnt > 3)
-                       pcnt = 3;
+               firstproc = 4;
+               if (VFSTOPROC(vp->v_mount)->pmnt_flags & PROCFSMNT_LINUXCOMPAT)
+                       firstproc += 2;
+               if (pcnt > firstproc)
+                       pcnt = firstproc;
 #ifdef PROCFS_ZOMBIE
        again:
 #endif

Reply via email to