Skip to content

Commit 318d016

Browse files
fs/ntfs3: Check for extremely large size of $AttrDef
Added additional checking for size of $AttrDef. Added comment. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 0addfb1 commit 318d016

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

fs/ntfs3/super.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,18 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
11851185
goto out;
11861186
}
11871187

1188-
if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
1188+
/*
1189+
* Typical $AttrDef contains up to 20 entries.
1190+
* Check for extremely large size.
1191+
*/
1192+
if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) ||
1193+
inode->i_size > 100 * sizeof(struct ATTR_DEF_ENTRY)) {
1194+
ntfs_err(sb, "Looks like $AttrDef is corrupted (size=%llu).",
1195+
inode->i_size);
11891196
err = -EINVAL;
11901197
goto put_inode_out;
11911198
}
1199+
11921200
bytes = inode->i_size;
11931201
sbi->def_table = t = kmalloc(bytes, GFP_NOFS | __GFP_NOWARN);
11941202
if (!t) {

0 commit comments

Comments
 (0)