Skip to content

Commit a9d6b06

Browse files
authored
ZIL: Fix another use-after-free.
lwb->lwb_issued_txg can not be accessed after lwb_state is set to LWB_STATE_FLUSH_DONE and zl_lock is dropped, since the lwb may be freed by zil_sync(). We must save the txg number before that. This is similar to the 55b1842, but as I see the bug is not new. It existed for quite a while, just was not triggered due to smaller race window. Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #14988 Closes #14999
1 parent b0cbc1a commit a9d6b06

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

module/zfs/zil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ zil_lwb_flush_vdevs_done(zio_t *zio)
14251425

14261426
list_move_tail(&itxs, &lwb->lwb_itxs);
14271427
list_move_tail(&waiters, &lwb->lwb_waiters);
1428+
txg = lwb->lwb_issued_txg;
14281429

14291430
ASSERT3S(lwb->lwb_state, ==, LWB_STATE_WRITE_DONE);
14301431
lwb->lwb_state = LWB_STATE_FLUSH_DONE;
@@ -1465,7 +1466,6 @@ zil_lwb_flush_vdevs_done(zio_t *zio)
14651466
list_destroy(&waiters);
14661467

14671468
mutex_enter(&zilog->zl_lwb_io_lock);
1468-
txg = lwb->lwb_issued_txg;
14691469
ASSERT3U(zilog->zl_lwb_inflight[txg & TXG_MASK], >, 0);
14701470
zilog->zl_lwb_inflight[txg & TXG_MASK]--;
14711471
if (zilog->zl_lwb_inflight[txg & TXG_MASK] == 0)

0 commit comments

Comments
 (0)