Skip to content

Commit 3408332

Browse files
authored
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: 8f15d2e Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Mateusz Piotrowski <mateusz.piotrowski@klarasystems.com>
1 parent 0f608aa commit 3408332

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/zhack.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,11 @@ zhack_do_metaslab_leak(int argc, char **argv)
745745
&start, &size), ==, 2);
746746

747747
ASSERT(vd);
748-
metaslab_t *cur =
749-
vd->vdev_ms[start >> vd->vdev_ms_shift];
748+
size_t idx;
749+
idx = start >> vd->vdev_ms_shift;
750+
if (idx >= vd->vdev_ms_count)
751+
continue;
752+
metaslab_t *cur = vd->vdev_ms[idx];
750753
if (prev != cur) {
751754
if (prev) {
752755
dmu_tx_commit(tx);

0 commit comments

Comments
 (0)