Skip to content

Commit 798a9ca

Browse files
Brian Fosterdjwong
authored andcommitted
xfs: fix mount failure crash on invalid iclog memory access
syzbot (via KASAN) reports a use-after-free in the error path of xlog_alloc_log(). Specifically, the iclog freeing loop doesn't handle the case of a fully initialized ->l_iclog linked list. Instead, it assumes that the list is partially constructed and NULL terminated. This bug manifested because there was no possible error scenario after iclog list setup when the original code was added. Subsequent code and associated error conditions were added some time later, while the original error handling code was never updated. Fix up the error loop to terminate either on a NULL iclog or reaching the end of the list. Reported-by: [email protected] Signed-off-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 69ffe59 commit 798a9ca

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/xfs/xfs_log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,8 @@ xlog_alloc_log(
15421542
prev_iclog = iclog->ic_next;
15431543
kmem_free(iclog->ic_data);
15441544
kmem_free(iclog);
1545+
if (prev_iclog == log->l_iclog)
1546+
break;
15451547
}
15461548
out_free_log:
15471549
kmem_free(log);

0 commit comments

Comments
 (0)