svn commit: r235781 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Edward Tomasz Napierala trasz at FreeBSD.org
Tue May 22 10:54:43 UTC 2012


Author: trasz
Date: Tue May 22 10:54:42 2012
New Revision: 235781
URL: http://svn.freebsd.org/changeset/base/235781

Log:
  Fix enforcement of file size limit with O_APPEND on ZFS.
  
  vn_rlimit_fsize takes uio->uio_offset and uio->uio_resid into account
  when determining whether given write would exceed RLIMIT_FSIZE.
  
  When APPEND flag is specified, ZFS updates uio->uio_offset to point to the
  end of file.
  
  But this happens after a call to vn_rlimit_fsize, so vn_rlimit_fsize check
  can be rendered ineffective by thread that opens some file with O_APPEND
  and lseeks below RLIMIT_FSIZE before calling write.
  
  Submitted by:	Mateusz Guzik <mjguzik at gmail dot com>
  MFC after:	2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue May 22 09:59:49 2012	(r235780)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue May 22 10:54:42 2012	(r235781)
@@ -838,6 +838,12 @@ zfs_write(vnode_t *vp, uio_t *uio, int i
 		rl = zfs_range_lock(zp, woff, n, RL_WRITER);
 	}
 
+	if (vn_rlimit_fsize(vp, uio, uio->uio_td)) {
+		zfs_range_unlock(rl);
+		ZFS_EXIT(zfsvfs);
+		return (EFBIG);
+	}
+
 	if (woff >= limit) {
 		zfs_range_unlock(rl);
 		ZFS_EXIT(zfsvfs);
@@ -5696,9 +5702,6 @@ zfs_freebsd_write(ap)
 	} */ *ap;
 {
 
-	if (vn_rlimit_fsize(ap->a_vp, ap->a_uio, ap->a_uio->uio_td))
-		return (EFBIG);
-
 	return (zfs_write(ap->a_vp, ap->a_uio, ioflags(ap->a_ioflag),
 	    ap->a_cred, NULL));
 }


More information about the svn-src-all mailing list