Skip to content

Commit 914bbc9

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 cbd95a9 commit 914bbc9

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
@@ -3712,16 +3712,19 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx)
37123712
spa_history_log_internal_ds(hds, "promote", tx, " ");
37133713

37143714
dsl_dir_rele(odd, FTAG);
3715-
promote_rele(ddpa, FTAG);
37163715

37173716
/*
3718-
* Transfer common error blocks from old head to new head.
3717+
* Transfer common error blocks from old head to new head, before
3718+
* calling promote_rele() on ddpa since we need to dereference
3719+
* origin_head and hds.
37193720
*/
37203721
if (spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_HEAD_ERRLOG)) {
37213722
uint64_t old_head = origin_head->ds_object;
37223723
uint64_t new_head = hds->ds_object;
37233724
spa_swap_errlog(dp->dp_spa, new_head, old_head, tx);
37243725
}
3726+
3727+
promote_rele(ddpa, FTAG);
37253728
}
37263729

37273730
/*

0 commit comments

Comments
 (0)