Skip to content

Commit

Permalink
ext4: Fix big-endian problem in __ext4_check_blockref()
Browse files Browse the repository at this point in the history
Commit fe2c819 introduced a regression on big-endian system, because
the checks to make sure block references in non-extent inodes are
valid failed to use le32_to_cpu().

Reported-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Thiemo Nagel <thiemo.nagel@ph.tum.de>
Tested-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
  • Loading branch information
Thiemo Nagel authored and Theodore Ts'o committed Apr 7, 2009
1 parent e0724bf commit f73953c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,16 @@ static int ext4_block_to_path(struct inode *inode,
}

static int __ext4_check_blockref(const char *function, struct inode *inode,
unsigned int *p, unsigned int max) {
__le32 *p, unsigned int max) {

unsigned int maxblocks = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es);
unsigned int *bref = p;
__le32 *bref = p;
while (bref < p+max) {
if (unlikely(*bref >= maxblocks)) {
if (unlikely(le32_to_cpu(*bref) >= maxblocks)) {
ext4_error(inode->i_sb, function,
"block reference %u >= max (%u) "
"in inode #%lu, offset=%d",
*bref, maxblocks,
le32_to_cpu(*bref), maxblocks,
inode->i_ino, (int)(bref-p));
return -EIO;
}
Expand Down

0 comments on commit f73953c

Please sign in to comment.