From e79cd79cd9c25128d7c0b3875bb9844926454a0c Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 16 Jul 2021 09:19:59 -0400 Subject: [PATCH] Initialize "autoreplace" in spa_ld_get_props() spa_prop_find() may fail to find the specified property, in which case it suppresses ENOENT from zap_lookup(). In this case, the return value is left uninitialized, so spa_autoreplace was being initialized using an uninitialized stack variable. This was found using KMSAN. It appears to be a regression from commit 9eb7b46ed0, which removed the initialization of "autoreplace" from the definition. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Mark Johnston Closes #12383 --- module/zfs/spa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 58066b824762..53e391f386ad 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -4183,7 +4183,7 @@ spa_ld_get_props(spa_t *spa) return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO)); if (error == 0) { - uint64_t autoreplace; + uint64_t autoreplace = 0; spa_prop_find(spa, ZPOOL_PROP_BOOTFS, &spa->spa_bootfs); spa_prop_find(spa, ZPOOL_PROP_AUTOREPLACE, &autoreplace);