add patch fix-checks-for-data-ordered-and-journal_async_commit-options
[ext4-patch-queue.git] / fix-inode-checksum-calculation-if-i_extra_size-is-too-small
blob949103bb5aadce75c6c7b7b4190a4300656d5d7f
1 ext4: fix inode checksum calculation problem if i_extra_size is small
3 From: Daeho Jeong <daeho.jeong@samsung.com>
5 We've fixed the race condition problem in calculating ext4 checksum
6 value in commit b47820edd163 ("ext4: avoid modifying checksum fields
7 directly during checksum veficationon"). However, by this change,
8 when calculating the checksum value of inode whose i_extra_size is
9 less than 4, we couldn't calculate the checksum value in a proper way.
10 This problem was found and reported by Nix, Thank you.
12 Reported-by: Nix <nix@esperi.org.uk>
13 Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
14 Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
15 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
18  fs/ext4/inode.c |    5 ++---
19  1 file changed, 2 insertions(+), 3 deletions(-)
21 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
22 index 9c06472..eaab3c3 100644
23 --- a/fs/ext4/inode.c
24 +++ b/fs/ext4/inode.c
25 @@ -71,10 +71,9 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
26                         csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum,
27                                            csum_size);
28                         offset += csum_size;
29 -                       csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
30 -                                          EXT4_INODE_SIZE(inode->i_sb) -
31 -                                          offset);
32                 }
33 +               csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
34 +                                  EXT4_INODE_SIZE(inode->i_sb) - offset);
35         }
37         return csum;
38 -- 
39 1.7.9.5