diff options
author | Chao Yu <chao@kernel.org> | 2021-08-06 08:02:50 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-08-17 11:59:06 -0700 |
commit | bbe1da7e34ac5a830163bfdfa09cbe3dadfda3ce (patch) | |
tree | 804f9537149283a4b182b6817c7cf9952880aeda /fs/f2fs/data.c | |
parent | b35d71b969096422f1c57d7c1394fe8b1cad9710 (diff) | |
download | linux-stable-bbe1da7e34ac5a830163bfdfa09cbe3dadfda3ce.tar.gz linux-stable-bbe1da7e34ac5a830163bfdfa09cbe3dadfda3ce.tar.bz2 linux-stable-bbe1da7e34ac5a830163bfdfa09cbe3dadfda3ce.zip |
f2fs: compress: do sanity check on cluster
This patch adds f2fs_sanity_check_cluster() to support doing
sanity check on cluster of compressed file, it will be triggered
from below two paths:
- __f2fs_cluster_blocks()
- f2fs_map_blocks(F2FS_GET_BLOCK_FIEMAP)
And it can detect below three kind of cluster insanity status.
C: COMPRESS_ADDR
N: NULL_ADDR or NEW_ADDR
V: valid blkaddr
*: any value
1. [*|C|*|*]
2. [C|*|C|*]
3. [C|N|N|V]
Signed-off-by: Chao Yu <chao@kernel.org>
[Nathan Chancellor: fix missing inline warning]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 12cd63603137..e4e4eb800d2b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1552,6 +1552,13 @@ next_block: map->m_flags |= F2FS_MAP_NEW; blkaddr = dn.data_blkaddr; } else { + if (f2fs_compressed_file(inode) && + f2fs_sanity_check_cluster(&dn) && + (flag != F2FS_GET_BLOCK_FIEMAP || + IS_ENABLED(CONFIG_F2FS_CHECK_FS))) { + err = -EFSCORRUPTED; + goto sync_out; + } if (flag == F2FS_GET_BLOCK_BMAP) { map->m_pblk = 0; goto sync_out; |