diff options
author | LOLi <[email protected]> | 2017-07-24 21:56:49 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-07-24 12:56:49 -0700 |
commit | 871e07321cc66fcea4dccc88fd2a754959ffa679 (patch) | |
tree | 4caf17ffa3a18dea98ac79aa3b8901f4c5d23db1 | |
parent | 83a5e4d6b9c2509efa25ea4cfceba3cd313bf920 (diff) |
Fix buffer overflow in dsl_dataset_name()
If we're creating a pool with version >= SPA_VERSION_DSL_SCRUB (v11)
we need to account for additional space needed by the origin dataset
which will also be snapshotted: "poolname"+"/"+"$ORIGIN"+"@"+"$ORIGIN".
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #6374
-rw-r--r-- | module/zcommon/zfs_namecheck.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/module/zcommon/zfs_namecheck.c b/module/zcommon/zfs_namecheck.c index f9c20896d..e8db93be7 100644 --- a/module/zcommon/zfs_namecheck.c +++ b/module/zcommon/zfs_namecheck.c @@ -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" @@ -300,8 +301,14 @@ pool_namecheck(const char *pool, namecheck_err_t *why, char *what) /* * 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); |