zhack: Fix importing large allocation profiles on small pools (#18256)

This patch fixes a segmentation fault in zhack metaslab leak which might
be triggered by feeding zhack with a fragmentation profile that's
exported from a pool larger than the target pool.

Fixes: 8f15d2e4d5
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Paul Dagnelie <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>

Signed-off-by: Mateusz Piotrowski <[email protected]>
This commit is contained in:
Mateusz Piotrowski authored and GitHub committed 2026-02-24 10:24:22 -08:00
1 parent 0f608aa6ca
commit 3408332d71
1 file changed
+5 -2
+5 -2
View File
@@ -745,8 +745,11 @@ zhack_do_metaslab_leak(int argc, char **argv)
&start, &size), ==, 2);
ASSERT(vd);
metaslab_t *cur =
vd->vdev_ms[start >> vd->vdev_ms_shift];
size_t idx;
idx = start >> vd->vdev_ms_shift;
if (idx >= vd->vdev_ms_count)
continue;
metaslab_t *cur = vd->vdev_ms[idx];
if (prev != cur) {
if (prev) {
dmu_tx_commit(tx);