diff options
| author | Samuel Moelius <sam.moelius@trailofbits.com> | 2026-06-03 15:11:40 +0000 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2026-06-22 19:52:36 +0000 |
| commit | cfcd0e49a178b3dac2c0ece656079081dbf5da74 (patch) | |
| tree | 9530e49895ea945356dd4ed4abd95816b1f352c6 | |
| parent | a41075acde0124d2f8a5f563068a5d63e8ffd57b (diff) | |
| download | lwn-cfcd0e49a178b3dac2c0ece656079081dbf5da74.tar.gz lwn-cfcd0e49a178b3dac2c0ece656079081dbf5da74.zip | |
f2fs: validate inline dentry name lengths before conversion
Inline dentry conversion copies names out of the inline dentry area
before checking that each recorded name length fits in the available
filename slots.
A corrupted image can therefore make the conversion path read past
the inline filename storage while building the regular dentry block.
Validate each inline dentry name length against the inline filename
area before copying it.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| -rw-r--r-- | fs/f2fs/inline.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 099f72089701..e2f7bedf1552 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -510,6 +510,12 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry) bit_pos++; continue; } + if (unlikely(le16_to_cpu(de->name_len) > F2FS_NAME_LEN || + bit_pos + GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)) > + d.max)) { + err = -EFSCORRUPTED; + goto punch_dentry_pages; + } /* * We only need the disk_name and hash to move the dentry. @@ -530,6 +536,7 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry) bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); } return 0; + punch_dentry_pages: truncate_inode_pages(&dir->i_data, 0); f2fs_truncate_blocks(dir, 0, false); |
