Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Nov 2017 22:44:51 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r325909 - stable/11/sys/cddl/contrib/opensolaris/common/zfs
Message-ID:  <201711162244.vAGMipHH054927@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Nov 16 22:44:51 2017
New Revision: 325909
URL: https://svnweb.freebsd.org/changeset/base/325909

Log:
  MFC r325606: MFV r325605: 8713 Buffer overflow in dsl_dataset_name()

Modified:
  stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c	Thu Nov 16 22:37:03 2017	(r325908)
+++ stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c	Thu Nov 16 22:44:51 2017	(r325909)
@@ -44,6 +44,7 @@
 #include <string.h>
 #endif
 
+#include <sys/dsl_dir.h>
 #include <sys/param.h>
 #include <sys/nvpair.h>
 #include "zfs_namecheck.h"
@@ -301,8 +302,14 @@ pool_namecheck(const char *pool, namecheck_err_t *why,
 
 	/*
 	 * Make sure the name is not too long.
+	 * If we're creating a pool with version >= SPA_VERSION_DSL_SCRUB (v11)
+	 * we need to account for additional space needed by the origin ds which
+	 * will also be snapshotted: "poolname"+"/"+"$ORIGIN"+"@"+"$ORIGIN".
+	 * Play it safe and enforce this limit even if the pool version is < 11
+	 * so it can be upgraded without issues.
 	 */
-	if (strlen(pool) >= ZFS_MAX_DATASET_NAME_LEN) {
+	if (strlen(pool) >= (ZFS_MAX_DATASET_NAME_LEN - 2 -
+	    strlen(ORIGIN_DIR_NAME) * 2)) {
 		if (why)
 			*why = NAME_ERR_TOOLONG;
 		return (-1);



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