diff options
author | Dave Chinner <david@fromorbit.com> | 2009-01-21 23:37:47 -0500 |
---|---|---|
committer | Felix Blyakher <felixb@sgi.com> | 2009-02-03 12:01:32 -0500 |
commit | 6139a2360987f55e4490a7813cf69df74ec8b93a (patch) | |
tree | 650a4ac7ef9181b0e98cae627728eae2b260c33d /fs | |
parent | 6d2160bfe7826aca1c94b4bca77093908a452ae7 (diff) |
xfs: Check buffer lengths in log recovery
Before trying to obtain, read or write a buffer,
check that the buffer length is actually valid. If
it is not valid, then something read in the recovery
process has been corrupted and we should abort
recovery.
Reported-by: Eric Sesterhenn <snakebyte@gmx.de>
Tested-by: Eric Sesterhenn <snakebyte@gmx.de>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 35cca98bd94c..b1047de2fffd 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -70,16 +70,21 @@ STATIC void xlog_recover_check_summary(xlog_t *); | |||
70 | xfs_buf_t * | 70 | xfs_buf_t * |
71 | xlog_get_bp( | 71 | xlog_get_bp( |
72 | xlog_t *log, | 72 | xlog_t *log, |
73 | int num_bblks) | 73 | int nbblks) |
74 | { | 74 | { |
75 | ASSERT(num_bblks > 0); | 75 | if (nbblks <= 0 || nbblks > log->l_logBBsize) { |
76 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); | ||
77 | XFS_ERROR_REPORT("xlog_get_bp(1)", | ||
78 | XFS_ERRLEVEL_HIGH, log->l_mp); | ||
79 | return NULL; | ||
80 | } | ||
76 | 81 | ||
77 | if (log->l_sectbb_log) { | 82 | if (log->l_sectbb_log) { |
78 | if (num_bblks > 1) | 83 | if (nbblks > 1) |
79 | num_bblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1); | 84 | nbblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1); |
80 | num_bblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, num_bblks); | 85 | nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); |
81 | } | 86 | } |
82 | return xfs_buf_get_noaddr(BBTOB(num_bblks), log->l_mp->m_logdev_targp); | 87 | return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp); |
83 | } | 88 | } |
84 | 89 | ||
85 | void | 90 | void |
@@ -102,6 +107,13 @@ xlog_bread( | |||
102 | { | 107 | { |
103 | int error; | 108 | int error; |
104 | 109 | ||
110 | if (nbblks <= 0 || nbblks > log->l_logBBsize) { | ||
111 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); | ||
112 | XFS_ERROR_REPORT("xlog_bread(1)", | ||
113 | XFS_ERRLEVEL_HIGH, log->l_mp); | ||
114 | return EFSCORRUPTED; | ||
115 | } | ||
116 | |||
105 | if (log->l_sectbb_log) { | 117 | if (log->l_sectbb_log) { |
106 | blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); | 118 | blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); |
107 | nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); | 119 | nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); |
@@ -139,6 +151,13 @@ xlog_bwrite( | |||
139 | { | 151 | { |
140 | int error; | 152 | int error; |
141 | 153 | ||
154 | if (nbblks <= 0 || nbblks > log->l_logBBsize) { | ||
155 | xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); | ||
156 | XFS_ERROR_REPORT("xlog_bwrite(1)", | ||
157 | XFS_ERRLEVEL_HIGH, log->l_mp); | ||
158 | return EFSCORRUPTED; | ||
159 | } | ||
160 | |||
142 | if (log->l_sectbb_log) { | 161 | if (log->l_sectbb_log) { |
143 | blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); | 162 | blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); |
144 | nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); | 163 | nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); |