diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-11-06 09:11:23 -0800 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-11-07 13:00:54 -0800 |
commit | d6abecb82573fed5f7e4b595b5c0bd37707d2848 (patch) | |
tree | d74ff7feb86114da3fb62e8bedaa4d84f111ea4b /fs/xfs/xfs_log_recover.c | |
parent | 120254608f042e01e0ad1da9285006f122943a1e (diff) | |
download | linux-rpi-d6abecb82573fed5f7e4b595b5c0bd37707d2848.tar.gz linux-rpi-d6abecb82573fed5f7e4b595b5c0bd37707d2848.tar.bz2 linux-rpi-d6abecb82573fed5f7e4b595b5c0bd37707d2848.zip |
xfs: range check ri_cnt when recovering log items
Range check the region counter when we're reassembling regions from log
items during log recovery. In the old days ASSERT would halt the
kernel, but this isn't true any more so we have to make an explicit
error return.
Coverity-id: 1132508
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 648d5ecafd91..b0257ef9d29f 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4301,7 +4301,16 @@ xlog_recover_add_to_trans( kmem_zalloc(item->ri_total * sizeof(xfs_log_iovec_t), 0); } - ASSERT(item->ri_total > item->ri_cnt); + + if (item->ri_total <= item->ri_cnt) { + xfs_warn(log->l_mp, + "log item region count (%d) overflowed size (%d)", + item->ri_cnt, item->ri_total); + ASSERT(0); + kmem_free(ptr); + return -EFSCORRUPTED; + } + /* Description region is ri_buf[0] */ item->ri_buf[item->ri_cnt].i_addr = ptr; item->ri_buf[item->ri_cnt].i_len = len; |