]> granicus.if.org Git - zfs/commitdiff
Illumos 5946, 5945
authorAndriy Gapon <avg@freebsd.org>
Thu, 2 Jul 2015 13:04:35 +0000 (16:04 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 6 Jul 2015 16:31:30 +0000 (09:31 -0700)
5946 zfs_ioc_space_snaps must check that firstsnap and lastsnap refer to snapshots
5945 zfs_ioc_send_space must ensure that fromsnap refers to a snapshot
Reviewed by: Steven Hartland <killing@multiplay.co.uk>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>

References:
  https://www.illumos.org/issues/5946
  https://www.illumos.org/issues/5945
  https://github.com/illumos/illumos-gate/commit/24218be

Ported-by: Andriy Gapon <avg@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3552

module/zfs/dmu_send.c
module/zfs/zfs_ioctl.c

index 340926785c1189efc022845b30383cecd935b51a..b2d844eb42561523037f47451ff2a4a50db20c38 100644 (file)
@@ -882,6 +882,10 @@ dmu_send_estimate(dsl_dataset_t *ds, dsl_dataset_t *fromds, uint64_t *sizep)
        if (!ds->ds_is_snapshot)
                return (SET_ERROR(EINVAL));
 
+       /* fromsnap, if provided, must be a snapshot */
+       if (fromds != NULL && !fromds->ds_is_snapshot)
+               return (SET_ERROR(EINVAL));
+
        /*
         * fromsnap must be an earlier snapshot from the same fs as tosnap,
         * or the origin's fs.
index 0eef257f13c789d9c9a148e0976b28d34011d236..c44927036aa3fa2ee26a65acb1aebb112dae27b5 100644 (file)
@@ -5171,11 +5171,19 @@ zfs_ioc_space_snaps(const char *lastsnap, nvlist_t *innvl, nvlist_t *outnvl)
                return (error);
 
        error = dsl_dataset_hold(dp, lastsnap, FTAG, &new);
+       if (error == 0 && !new->ds_is_snapshot) {
+               dsl_dataset_rele(new, FTAG);
+               error = SET_ERROR(EINVAL);
+       }
        if (error != 0) {
                dsl_pool_rele(dp, FTAG);
                return (error);
        }
        error = dsl_dataset_hold(dp, firstsnap, FTAG, &old);
+       if (error == 0 && !old->ds_is_snapshot) {
+               dsl_dataset_rele(old, FTAG);
+               error = SET_ERROR(EINVAL);
+       }
        if (error != 0) {
                dsl_dataset_rele(new, FTAG);
                dsl_pool_rele(dp, FTAG);