summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2019-12-03 07:53:15 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-12 11:22:40 +0100
commit03e47594564a435e6c2890142476b93e82090c2e (patch)
tree9ec4f2dd3485cba0f03b2c82af0f0b08a3544e7e /fs
parent91f060f5c5c8fe3b8d171e1d191512c400780352 (diff)
downloadlinux-stable-03e47594564a435e6c2890142476b93e82090c2e.tar.gz
linux-stable-03e47594564a435e6c2890142476b93e82090c2e.tar.bz2
linux-stable-03e47594564a435e6c2890142476b93e82090c2e.zip
xfs: fix mount failure crash on invalid iclog memory access
[ Upstream commit 798a9cada4694ca8d970259f216cec47e675bfd5 ] 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: syzbot+c732f8644185de340492@syzkaller.appspotmail.com Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_log.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 73b725f965eb..065aa4752607 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1503,6 +1503,8 @@ out_free_iclog:
if (iclog->ic_bp)
xfs_buf_free(iclog->ic_bp);
kmem_free(iclog);
+ if (prev_iclog == log->l_iclog)
+ break;
}
spinlock_destroy(&log->l_icloglock);
xfs_buf_free(log->l_xbuf);