Skip to content

Commit 43e574b

Browse files
committed
head_errlog: fix use-after-free
In the commit of the head_errlog feature we introduced a bug in dsl_dataset_promote_sync(): we may dereference origin_head and hds, both dereferencing ddpa after calling promote_sync() on ddpa. Closes: #16272 Signed-off-by: George Amanakis <[email protected]>
1 parent 2eab4f7 commit 43e574b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

module/zfs/dsl_dataset.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,16 +3710,19 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx)
37103710
spa_history_log_internal_ds(hds, "promote", tx, " ");
37113711

37123712
dsl_dir_rele(odd, FTAG);
3713-
promote_rele(ddpa, FTAG);
37143713

37153714
/*
3716-
* Transfer common error blocks from old head to new head.
3715+
* Transfer common error blocks from old head to new head, before
3716+
* calling promote_rele() on ddpa since we need to dereference
3717+
* origin_head and hds.
37173718
*/
37183719
if (spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_HEAD_ERRLOG)) {
37193720
uint64_t old_head = origin_head->ds_object;
37203721
uint64_t new_head = hds->ds_object;
37213722
spa_swap_errlog(dp->dp_spa, new_head, old_head, tx);
37223723
}
3724+
3725+
promote_rele(ddpa, FTAG);
37233726
}
37243727

37253728
/*

0 commit comments

Comments
 (0)