Print this page
6223 libzfs improperly uses an avl tree in namespace_reload

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_config.c
          +++ new/usr/src/lib/libzfs/common/libzfs_config.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   * Copyright (c) 2012 by Delphix. All rights reserved.
       29 + * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  29   30   */
  30   31  
  31   32  /*
  32   33   * The pool configuration repository is stored in /etc/zfs/zpool.cache as a
  33   34   * single packed nvlist.  While it would be nice to just read in this
  34   35   * file from userland, this wouldn't work from a local zone.  So we have to have
  35   36   * a zpool ioctl to return the complete configuration for all pools.  In the
  36   37   * global zone, this will be identical to reading the file and unpacking it in
  37   38   * userland.
  38   39   */
↓ open down ↓ 121 lines elided ↑ open up ↑
 160  161          }
 161  162  
 162  163          if (zcmd_read_dst_nvlist(hdl, &zc, &config) != 0) {
 163  164                  zcmd_free_nvlists(&zc);
 164  165                  return (-1);
 165  166          }
 166  167  
 167  168          zcmd_free_nvlists(&zc);
 168  169  
 169  170          /*
 170      -         * Clear out any existing configuration information.
      171 +         * Clear out any existing configuration information, and recreate
      172 +         * the AVL tree.
 171  173           */
 172  174          cookie = NULL;
 173  175          while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, &cookie)) != NULL) {
 174  176                  nvlist_free(cn->cn_config);
 175  177                  free(cn->cn_name);
 176  178                  free(cn);
 177  179          }
      180 +
      181 +        uu_avl_recreate(hdl->libzfs_ns_avl);
 178  182  
 179  183          elem = NULL;
 180  184          while ((elem = nvlist_next_nvpair(config, elem)) != NULL) {
 181  185                  nvlist_t *child;
 182  186                  uu_avl_index_t where;
 183  187  
 184  188                  if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) {
 185  189                          nvlist_free(config);
 186  190                          return (-1);
 187  191                  }
↓ open down ↓ 266 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX