Skip to content

Commit 51f8d95

Browse files
daehojeonggregkh
authored andcommitted
ext4: fix inode checksum calculation problem if i_extra_size is small
commit 05ac5aa18abd7db341e54df4ae2b4c98ea0e43b7 upstream. We've fixed the race condition problem in calculating ext4 checksum value in commit b47820edd163 ("ext4: avoid modifying checksum fields directly during checksum veficationon"). However, by this change, when calculating the checksum value of inode whose i_extra_size is less than 4, we couldn't calculate the checksum value in a proper way. This problem was found and reported by Nix, Thank you. Reported-by: Nix <nix@esperi.org.uk> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com> Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0cb03b6 commit 51f8d95

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

fs/ext4/inode.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
7171
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum,
7272
csum_size);
7373
offset += csum_size;
74-
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
75-
EXT4_INODE_SIZE(inode->i_sb) -
76-
offset);
7774
}
75+
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
76+
EXT4_INODE_SIZE(inode->i_sb) - offset);
7877
}
7978

8079
return csum;

0 commit comments

Comments
 (0)