diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-03-03 14:48:36 -0500 |
---|---|---|
committer | Felix Blyakher <felixb@sgi.com> | 2009-03-06 18:34:45 -0500 |
commit | ff392c497b43ddedbab5627b53928a654cc5486e (patch) | |
tree | 3ba2bf44750f902b3480233307d6e1c4129b695a /fs | |
parent | 27e88bf6af7d42adf790f7b2ed7d65475f191cf2 (diff) |
xfs: prevent kernel crash due to corrupted inode log format
Andras Korn reported an oops on log replay causes by a corrupted
xfs_inode_log_format_t passing a 0 size to kmem_zalloc. This patch handles
to small or too large numbers of log regions gracefully by rejecting the
log replay with a useful error message.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Andras Korn <korn-sgi.com@chardonnay.math.bme.hu>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index b1047de2fffd..61af610d79b3 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -1455,10 +1455,19 @@ xlog_recover_add_to_trans( | |||
1455 | item = item->ri_prev; | 1455 | item = item->ri_prev; |
1456 | 1456 | ||
1457 | if (item->ri_total == 0) { /* first region to be added */ | 1457 | if (item->ri_total == 0) { /* first region to be added */ |
1458 | item->ri_total = in_f->ilf_size; | 1458 | if (in_f->ilf_size == 0 || |
1459 | ASSERT(item->ri_total <= XLOG_MAX_REGIONS_IN_ITEM); | 1459 | in_f->ilf_size > XLOG_MAX_REGIONS_IN_ITEM) { |
1460 | item->ri_buf = kmem_zalloc((item->ri_total * | 1460 | xlog_warn( |
1461 | sizeof(xfs_log_iovec_t)), KM_SLEEP); | 1461 | "XFS: bad number of regions (%d) in inode log format", |
1462 | in_f->ilf_size); | ||
1463 | ASSERT(0); | ||
1464 | return XFS_ERROR(EIO); | ||
1465 | } | ||
1466 | |||
1467 | item->ri_total = in_f->ilf_size; | ||
1468 | item->ri_buf = | ||
1469 | kmem_zalloc(item->ri_total * sizeof(xfs_log_iovec_t), | ||
1470 | KM_SLEEP); | ||
1462 | } | 1471 | } |
1463 | ASSERT(item->ri_total > item->ri_cnt); | 1472 | ASSERT(item->ri_total > item->ri_cnt); |
1464 | /* Description region is ri_buf[0] */ | 1473 | /* Description region is ri_buf[0] */ |