Check permissions in zfs_space().
authorEtienne Dechamps <etienne.dechamps@ovh.net>
Fri, 2 Sep 2011 07:37:53 +0000 (09:37 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 9 Feb 2012 23:20:37 +0000 (15:20 -0800)
This isn't done on Solaris because on this OS zfs_space() can
only be called with an opened file handle. Since the addition of
zpl_truncate_range() this isn't the case anymore, so we need to
enforce access rights.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #334

module/zfs/zfs_vnops.c

index c139198..74b96b8 100644 (file)
@@ -4155,6 +4155,17 @@ zfs_space(struct inode *ip, int cmd, flock64_t *bfp, int flag,
                return (EINVAL);
        }
 
+       /*
+        * Permissions aren't checked on Solaris because on this OS
+        * zfs_space() can only be called with an opened file handle.
+        * On Linux we can get here through truncate_range() which
+        * operates directly on inodes, so we need to check access rights.
+        */
+       if ((error = zfs_zaccess(zp, ACE_WRITE_DATA, 0, B_FALSE, cr))) {
+               ZFS_EXIT(zsb);
+               return (error);
+       }
+
        off = bfp->l_start;
        len = bfp->l_len; /* 0 means from off to end of file */