Skip to content

Commit

Permalink
f2fs: Restrict max filesize for 16K f2fs
Browse files Browse the repository at this point in the history
[ Upstream commit a6a010f ]

Blocks are tracked by u32, so the max permitted filesize is
(U32_MAX + 1) * BLOCK_SIZE. Additionally, in order to support crypto
data unit sizes of 4K with a 16K block with IV_INO_LBLK_{32,64}, we must
further restrict max filesize to (U32_MAX + 1) * 4096. This does not
affect 4K blocksize f2fs as the natural limit for files are well below
that.

Fixes: d7e9a90 ("f2fs: Support Block Size == Page Size")
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
drosen-google authored and gregkh committed Jan 25, 2024
1 parent 18b951e commit cc16c86
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/f2fs/super.c
Expand Up @@ -3364,6 +3364,14 @@ loff_t max_file_blocks(struct inode *inode)
leaf_count *= NIDS_PER_BLOCK;
result += leaf_count;

/*
* For compatibility with FSCRYPT_POLICY_FLAG_IV_INO_LBLK_{64,32} with
* a 4K crypto data unit, we must restrict the max filesize to what can
* fit within U32_MAX + 1 data units.
*/

result = min(result, (((loff_t)U32_MAX + 1) * 4096) >> F2FS_BLKSIZE_BITS);

return result;
}

Expand Down

0 comments on commit cc16c86

Please sign in to comment.