OpenZFS 6876 - Stack corruption after importing a pool with a too-long name

Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>

Calling dsl_dataset_name on a dataset with a 256 byte buffer is asking
for trouble. We should check every dataset on import, using a 1024 byte
buffer and checking each time to see if the dataset's new name is longer
than 256 bytes.

OpenZFS-issue: https://www.illumos.org/issues/6876
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/ca8674e
This commit is contained in:
Paul Dagnelie
2016-06-15 14:51:27 -07:00
committed by Brian Behlendorf
parent eca7b76001
commit d1d19c7854
3 changed files with 36 additions and 2 deletions
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -92,6 +92,8 @@ function cleanup
[[ -d $ALTER_ROOT ]] && \
log_must $RM -rf $ALTER_ROOT
[[ -e $VDEV_FILE ]] && \
log_must $RM $VDEV_FILE
}
log_onexit cleanup
@@ -159,4 +161,13 @@ while (( i < ${#pools[*]} )); do
((i = i + 1))
done
VDEV_FILE=$(mktemp /tmp/tmp.XXXXXX)
log_must $MKFILE -n 128M $VDEV_FILE
log_must $ZPOOL create testpool $VDEV_FILE
log_must $ZFS create testpool/testfs
ID=$($ZPOOL get -Ho value guid testpool)
log_must $ZPOOL export testpool
log_mustnot $ZPOOL import $(echo $ID) $($PRINTF "%*s\n" 250 "" | $TR ' ' 'c')
log_pass "Successfully imported and renamed a ZPOOL"