Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jun 2012 20:27:41 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r236636 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201206052027.q55KRfJa042195@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Tue Jun  5 20:27:41 2012
New Revision: 236636
URL: http://svn.freebsd.org/changeset/base/236636

Log:
  MFC r235781:
  
  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.

Modified:
  stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue Jun  5 20:22:37 2012	(r236635)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue Jun  5 20:27:41 2012	(r236636)
@@ -839,6 +839,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);
@@ -5697,9 +5703,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));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206052027.q55KRfJa042195>