From: Hrutvik Kanabar <hrkanabar@gmail.com>
To: Hrutvik Kanabar <hrutvik@google.com>
Cc: "Darrick J . Wong" <djwong@kernel.org>, Chris Mason <clm@fb.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
kasan-dev@googlegroups.com, linux-ext4@vger.kernel.org,
Namjae Jeon <linkinjeon@kernel.org>,
Marco Elver <elver@google.com>,
Josef Bacik <josef@toxicpanda.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
David Sterba <dsterba@suse.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Anton Altaparmakov <anton@tuxera.com>,
Theodore Ts'o <tytso@mit.edu>,
linux-ntfs-dev@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-xfs@vger.kernel.org, Aleksandr Nogikh <nogikh@google.com>,
linux-fsdevel@vger.kernel.org,
Sungjong Seo <sj1557.seo@samsung.com>,
linux-btrfs@vger.kernel.org
Subject: [f2fs-dev] [PATCH RFC 7/7] fs/f2fs: support `DISABLE_FS_CSUM_VERIFICATION` config option
Date: Fri, 14 Oct 2022 08:48:37 +0000 [thread overview]
Message-ID: <20221014084837.1787196-8-hrkanabar@gmail.com> (raw)
In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com>
From: Hrutvik Kanabar <hrutvik@google.com>
When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum
verification.
Signed-off-by: Hrutvik Kanabar <hrutvik@google.com>
---
fs/f2fs/checkpoint.c | 3 ++-
fs/f2fs/compress.c | 3 ++-
fs/f2fs/f2fs.h | 2 ++
fs/f2fs/inode.c | 3 +++
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 0c82dae082aa..cc5043fbffcb 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -864,7 +864,8 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
}
crc = f2fs_checkpoint_chksum(sbi, *cp_block);
- if (crc != cur_cp_crc(*cp_block)) {
+ if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) &&
+ crc != cur_cp_crc(*cp_block)) {
f2fs_put_page(*cp_page, 1);
f2fs_warn(sbi, "invalid crc value");
return -EINVAL;
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index d315c2de136f..d0bce92dbf38 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -772,7 +772,8 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
u32 provided = le32_to_cpu(dic->cbuf->chksum);
u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
- if (provided != calculated) {
+ if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) &&
+ provided != calculated) {
if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {
set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
printk_ratelimited(
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..b27f1ec9b49f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1976,6 +1976,8 @@ static inline u32 f2fs_crc32(struct f2fs_sb_info *sbi, const void *address,
static inline bool f2fs_crc_valid(struct f2fs_sb_info *sbi, __u32 blk_crc,
void *buf, size_t buf_size)
{
+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION))
+ return true;
return f2fs_crc32(sbi, buf, buf_size) == blk_crc;
}
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 9f0d3864d9f1..239bb08e45b1 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -181,6 +181,9 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
#endif
return true;
+ if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION))
+ return true;
+
ri = &F2FS_NODE(page)->i;
provided = le32_to_cpu(ri->i_inode_checksum);
calculated = f2fs_inode_chksum(sbi, page);
--
2.38.0.413.g74048e4d9e-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2022-10-14 8:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 8:48 [f2fs-dev] [PATCH RFC 0/7] fs: Debug config option to disable filesystem checksum verification for fuzzing Hrutvik Kanabar
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 1/7] fs: create `DISABLE_FS_CSUM_VERIFICATION` config option Hrutvik Kanabar
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 2/7] fs/ext4: support " Hrutvik Kanabar
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 3/7] fs/btrfs: " Hrutvik Kanabar
2022-10-14 10:23 ` Qu Wenruo via Linux-f2fs-devel
2022-10-17 8:43 ` Dmitry Vyukov via Linux-f2fs-devel
2022-10-17 9:35 ` Qu Wenruo
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 4/7] fs/exfat: " Hrutvik Kanabar
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 5/7] fs/xfs: " Hrutvik Kanabar
2022-10-14 15:44 ` Darrick J. Wong
2022-10-17 8:32 ` Dmitry Vyukov via Linux-f2fs-devel
2022-10-14 8:48 ` [f2fs-dev] [PATCH RFC 6/7] fs/ntfs: " Hrutvik Kanabar
2022-10-14 8:48 ` Hrutvik Kanabar [this message]
2022-10-14 9:15 ` [f2fs-dev] [PATCH RFC 0/7] fs: Debug config option to disable filesystem checksum verification for fuzzing David Sterba
2022-10-17 8:31 ` Dmitry Vyukov via Linux-f2fs-devel
2022-10-17 12:02 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221014084837.1787196-8-hrkanabar@gmail.com \
--to=hrkanabar@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=anton@tuxera.com \
--cc=clm@fb.com \
--cc=djwong@kernel.org \
--cc=dsterba@suse.com \
--cc=elver@google.com \
--cc=hrutvik@google.com \
--cc=jaegeuk@kernel.org \
--cc=josef@toxicpanda.com \
--cc=kasan-dev@googlegroups.com \
--cc=linkinjeon@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=linux-xfs@vger.kernel.org \
--cc=nogikh@google.com \
--cc=sj1557.seo@samsung.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).