Commit f73953c0 authored by Thiemo Nagel's avatar Thiemo Nagel Committed by Theodore Ts'o

ext4: Fix big-endian problem in __ext4_check_blockref()

Commit fe2c8191 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: default avatarAlexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: default avatarThiemo Nagel <thiemo.nagel@ph.tum.de>
Tested-by: default avatarAlexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
parent e0724bf6
...@@ -372,16 +372,16 @@ static int ext4_block_to_path(struct inode *inode, ...@@ -372,16 +372,16 @@ static int ext4_block_to_path(struct inode *inode,
} }
static int __ext4_check_blockref(const char *function, 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 maxblocks = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es);
unsigned int *bref = p; __le32 *bref = p;
while (bref < p+max) { while (bref < p+max) {
if (unlikely(*bref >= maxblocks)) { if (unlikely(le32_to_cpu(*bref) >= maxblocks)) {
ext4_error(inode->i_sb, function, ext4_error(inode->i_sb, function,
"block reference %u >= max (%u) " "block reference %u >= max (%u) "
"in inode #%lu, offset=%d", "in inode #%lu, offset=%d",
*bref, maxblocks, le32_to_cpu(*bref), maxblocks,
inode->i_ino, (int)(bref-p)); inode->i_ino, (int)(bref-p));
return -EIO; return -EIO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment