Print this page
5515 dataset user hold doesn't reject empty tags

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_ioctl.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_ioctl.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Portions Copyright 2011 Martin Matuska
  25   25   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  26   26   * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  27   27   * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  28   28   * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  29   29   * Copyright (c) 2013 Steven Hartland. All rights reserved.
  30      - * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
       30 + * Copyright (c) 2015, Nexenta Systems, Inc. All rights reserved.
  31   31   */
  32   32  
  33   33  /*
  34   34   * ZFS ioctls.
  35   35   *
  36   36   * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  37   37   * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  38   38   *
  39   39   * There are two ways that we handle ioctls: the legacy way where almost
  40   40   * all of the logic is in the ioctl callback, and the new way where most
↓ open down ↓ 5062 lines elided ↑ open up ↑
5103 5103   *
5104 5104   * outnvl: {
5105 5105   *     snapname -> error value (int32)
5106 5106   *     ...
5107 5107   * }
5108 5108   */
5109 5109  /* ARGSUSED */
5110 5110  static int
5111 5111  zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
5112 5112  {
     5113 +        nvpair_t *pair;
5113 5114          nvlist_t *holds;
5114 5115          int cleanup_fd = -1;
5115 5116          int error;
5116 5117          minor_t minor = 0;
5117 5118  
5118 5119          error = nvlist_lookup_nvlist(args, "holds", &holds);
5119 5120          if (error != 0)
5120 5121                  return (SET_ERROR(EINVAL));
     5122 +
     5123 +        /* make sure the user didn't pass us any invalid (empty) tags */
     5124 +        for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
     5125 +            pair = nvlist_next_nvpair(holds, pair)) {
     5126 +                char *htag;
     5127 +
     5128 +                error = nvpair_value_string(pair, &htag);
     5129 +                if (error != 0)
     5130 +                        return (SET_ERROR(error));
     5131 +
     5132 +                if (strlen(htag) == 0)
     5133 +                        return (SET_ERROR(EINVAL));
     5134 +        }
5121 5135  
5122 5136          if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
5123 5137                  error = zfs_onexit_fd_hold(cleanup_fd, &minor);
5124 5138                  if (error != 0)
5125 5139                          return (error);
5126 5140          }
5127 5141  
5128 5142          error = dsl_dataset_user_hold(holds, minor, errlist);
5129 5143          if (minor != 0)
5130 5144                  zfs_onexit_fd_rele(cleanup_fd);
↓ open down ↓ 984 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX