NetBSD-Bugs archive

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

Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al



The following reply was made to PR kern/45634; it has been noted by GNATS.

From: Christian Biere <christianbiere%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al
Date: Wed, 23 Nov 2011 20:53:02 +0100

 This is a multi-part message in MIME format.
 
 --Multipart=_Wed__23_Nov_2011_20_53_02_+0100_odB7VCvGv/OwDNAR
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 The attached patch should avoid the mentioned integer overflows in vflushnext()
 by using the proper arithmetic methods and ensure that the conditional code is 
actually invoked when the declared amount of ticks has passed.
 
 --Multipart=_Wed__23_Nov_2011_20_53_02_+0100_odB7VCvGv/OwDNAR
 Content-Type: text/x-diff;
  name="vfs_mount.c.diff"
 Content-Disposition: attachment;
  filename="vfs_mount.c.diff"
 Content-Transfer-Encoding: 7bit
 
 --- vfs_mount.c.orig   2011-11-23 19:28:41.334186185 +0100
 +++ vfs_mount.c        2011-11-23 20:36:55.004184864 +0100
 @@ -420,14 +420,15 @@
  #endif
  
  static vnode_t *
 -vflushnext(vnode_t *mvp, int *when)
 +vflushnext(vnode_t *mvp, unsigned *when, unsigned dly)
  {
 +      unsigned dt = hardclock_ticks + dly - *when;
  
 -      if (hardclock_ticks > *when) {
 +      if (dt > dly) {
                mutex_exit(&mntvnode_lock);
                yield();
                mutex_enter(&mntvnode_lock);
 -              *when = hardclock_ticks + hz / 10;
 +              *when = hardclock_ticks + dly;
        }
        return vunmark(mvp);
  }
 @@ -436,7 +437,7 @@
  vflush(struct mount *mp, vnode_t *skipvp, int flags)
  {
        vnode_t *vp, *mvp;
 -      int busy = 0, when = 0;
 +      unsigned busy = 0, dly = 10 / hz, when = hardclock_ticks - dly - 1;
  
        /* First, flush out any vnode references from vrele_list. */
        vrele_flush();
 @@ -450,7 +451,7 @@
         */
        mutex_enter(&mntvnode_lock);
        for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp != NULL;
 -          vp = vflushnext(mvp, &when)) {
 +          vp = vflushnext(mvp, &when, dly)) {
                vmark(mvp, vp);
                if (vp->v_mount != mp || vismarker(vp))
                        continue;
 
 --Multipart=_Wed__23_Nov_2011_20_53_02_+0100_odB7VCvGv/OwDNAR--
 


Home | Main Index | Thread Index | Old Index