[PATCH RFC 4/7] fs/exfat: support `DISABLE_FS_CSUM_VERIFICATION` config option

Hrutvik Kanabar
2022-10-14T08:50:30Z

When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum
verification.

Signed-off-by: Hrutvik Kanabar <hrutvik@google.com>
---
fs/exfat/nls.c | 3 ++-
fs/exfat/super.c | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c
index 705710f93e2d..f0f92eaf6ccc 100644
--- a/fs/exfat/nls.c
+++ b/fs/exfat/nls.c
@@ -696,7 +696,8 @@ static int exfat_load_upcase_table(struct super_block *sb,
brelse(bh);
}

- if (index >= 0xFFFF && utbl_checksum == chksum)
+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) ||
+ (index >= 0xFFFF && utbl_checksum == chksum))
return 0;

exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)",
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 35f0305cd493..7418858792b3 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -564,6 +564,9 @@ static int exfat_verify_boot_region(struct super_block *sb)
if (!bh)
return -EIO;

+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION))
+ return 0;
+
for (i = 0; i < sb->s_blocksize; i += sizeof(u32)) {
p_chksum = (__le32 *)&bh->b_data[i];
if (le32_to_cpu(*p_chksum) != chksum) {
--
2.38.0.413.g74048e4d9e-goog