Author: kib
Date: Tue Feb  1 10:20:31 2011
New Revision: 218164
URL: http://svn.freebsd.org/changeset/base/218164

Log:
  MFC r217824:
  When vtruncbuf() iterates over the vnode buffer list, lock buffer object
  before checking the validity of the next buffer pointer. Otherwise, the
  buffer might be reclaimed after the check, causing iteration to run into
  wrong buffer.

Modified:
  stable/8/sys/kern/vfs_subr.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/vfs_subr.c
==============================================================================
--- stable/8/sys/kern/vfs_subr.c        Tue Feb  1 10:18:36 2011        
(r218163)
+++ stable/8/sys/kern/vfs_subr.c        Tue Feb  1 10:20:31 2011        
(r218164)
@@ -1340,13 +1340,14 @@ restart:
                        brelse(bp);
                        anyfreed = 1;
 
+                       BO_LOCK(bo);
                        if (nbp != NULL &&
                            (((nbp->b_xflags & BX_VNCLEAN) == 0) ||
                            (nbp->b_vp != vp) ||
                            (nbp->b_flags & B_DELWRI))) {
+                               BO_UNLOCK(bo);
                                goto restart;
                        }
-                       BO_LOCK(bo);
                }
 
                TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) {
@@ -1363,13 +1364,15 @@ restart:
                        bp->b_flags &= ~B_ASYNC;
                        brelse(bp);
                        anyfreed = 1;
+
+                       BO_LOCK(bo);
                        if (nbp != NULL &&
                            (((nbp->b_xflags & BX_VNDIRTY) == 0) ||
                            (nbp->b_vp != vp) ||
                            (nbp->b_flags & B_DELWRI) == 0)) {
+                               BO_UNLOCK(bo);
                                goto restart;
                        }
-                       BO_LOCK(bo);
                }
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to