From 8eb51f8d8f91a423dc5b108ada445c2162f6600d Mon Sep 17 00:00:00 2001 From: Hanjie Lin Date: Mon, 21 Oct 2019 19:22:02 +0800 Subject: [PATCH] ext4: always initialize the crc32c checksum driver [1/1] PD#SWPL-15901 Problem: OTT-6792 upstream a45403b51582a87872927a3e0fc0a389c26867f1 The extended attribute code now uses the crc32c checksum for hashing purposes, so we should just always always initialize it. We also want to prevent NULL pointer dereferences if one of the metadata checksum features is enabled after the file sytsem is originally mounted. This issue has been assigned CVE-2018-1094. https://bugzilla.kernel.org/show_bug.cgi?id=199183 https://bugzilla.redhat.com/show_bug.cgi?id=1560788 Solution: Verify: Change-Id: I30362945537ff4aa05fbf8e83dc52c25b3d24586 Signed-off-by: Theodore Ts'o Signed-off-by: Hanjie Lin --- fs/ext4/ext4.h | 3 ++- fs/ext4/super.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 5f3d2e2bdbdf..9929685bb39e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2696,7 +2696,8 @@ static inline int ext4_has_metadata_csum(struct super_block *sb) WARN_ON_ONCE(ext4_has_feature_metadata_csum(sb) && !EXT4_SB(sb)->s_chksum_driver); - return (EXT4_SB(sb)->s_chksum_driver != NULL); + return ext4_has_feature_metadata_csum(sb) && + (EXT4_SB(sb)->s_chksum_driver != NULL); } static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es) { diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ab72207d8f70..63d7bcb83f2a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3461,14 +3461,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } /* Load the checksum driver */ - if (ext4_has_feature_metadata_csum(sb)) { - sbi->s_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); - if (IS_ERR(sbi->s_chksum_driver)) { - ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); - ret = PTR_ERR(sbi->s_chksum_driver); - sbi->s_chksum_driver = NULL; - goto failed_mount; - } + sbi->s_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); + if (IS_ERR(sbi->s_chksum_driver)) { + ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver."); + ret = PTR_ERR(sbi->s_chksum_driver); + sbi->s_chksum_driver = NULL; + goto failed_mount; } /* Check superblock checksum */