ext4: fix big-endian bug in metadata checksum calculations
authorDmitry Monakhov <dmonakhov@openvz.org>
Wed, 10 Apr 2013 03:56:48 +0000 (23:56 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 10 Apr 2013 03:56:48 +0000 (23:56 -0400)
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
fs/ext4/inode.c
fs/ext4/mmp.c

index 629d67b62dfba56cc9009c6a54c56866f6149581..62189c84175fd75e618d038d4855de503ef5c0b6 100644 (file)
@@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
        __u16 csum_hi = 0;
        __u32 csum;
 
-       csum_lo = raw->i_checksum_lo;
+       csum_lo = le16_to_cpu(raw->i_checksum_lo);
        raw->i_checksum_lo = 0;
        if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
            EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
-               csum_hi = raw->i_checksum_hi;
+               csum_hi = le16_to_cpu(raw->i_checksum_hi);
                raw->i_checksum_hi = 0;
        }
 
        csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
                           EXT4_INODE_SIZE(inode->i_sb));
 
-       raw->i_checksum_lo = csum_lo;
+       raw->i_checksum_lo = cpu_to_le16(csum_lo);
        if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
            EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
-               raw->i_checksum_hi = csum_hi;
+               raw->i_checksum_hi = cpu_to_le16(csum_hi);
 
        return csum;
 }
index f9b551561d2cc424fa3b512ba3f0d7c4fc51c41b..b3b1f7d99448368c762139a3c844dc84596752c7 100644 (file)
@@ -7,7 +7,7 @@
 #include "ext4.h"
 
 /* Checksumming functions */
-static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
+static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
 {
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        int offset = offsetof(struct mmp_struct, mmp_checksum);