Author: kib
Date: Sun Feb 14 18:17:58 2016
New Revision: 295614
URL: https://svnweb.freebsd.org/changeset/base/295614

Log:
  MFC r294596:
  Limit the accesses to file' f_advice member to VREG vnodes only.
  Recheck that f_advice is not NULL after lock is taken.
  
  Approved by:  re (marius)

Modified:
  stable/10/sys/kern/vfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/vfs_vnops.c
==============================================================================
--- stable/10/sys/kern/vfs_vnops.c      Sun Feb 14 17:21:19 2016        
(r295613)
+++ stable/10/sys/kern/vfs_vnops.c      Sun Feb 14 18:17:58 2016        
(r295614)
@@ -733,12 +733,13 @@ get_advice(struct file *fp, struct uio *
        int ret;
 
        ret = POSIX_FADV_NORMAL;
-       if (fp->f_advice == NULL)
+       if (fp->f_advice == NULL || fp->f_vnode->v_type != VREG)
                return (ret);
 
        mtxp = mtx_pool_find(mtxpool_sleep, fp);
        mtx_lock(mtxp);
-       if (uio->uio_offset >= fp->f_advice->fa_start &&
+       if (fp->f_advice != NULL &&
+           uio->uio_offset >= fp->f_advice->fa_start &&
            uio->uio_offset + uio->uio_resid <= fp->f_advice->fa_end)
                ret = fp->f_advice->fa_advice;
        mtx_unlock(mtxp);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to