Skip to content

Commit d98e4d9

Browse files
desmondcheongzxtorvalds
authored andcommitted
ntfs: fix validity check for file name attribute
When checking the file name attribute, we want to ensure that it fits within the bounds of ATTR_RECORD. To do this, we should check that (attr record + file name offset + file name length) < (attr record + attr record length). However, the original check did not include the file name offset in the calculation. This means that corrupted on-disk metadata might not caught by the incorrect file name check, and lead to an invalid memory access. An example can be seen in the crash report of a memory corruption error found by Syzbot: https://syzkaller.appspot.com/bug?id=a1a1e379b225812688566745c3e2f7242bffc246 Adding the file name offset to the validity check fixes this error and passes the Syzbot reproducer test. Link: https://lkml.kernel.org/r/20210614050540.289494-1-desmondcheongzx@gmail.com Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com> Reported-by: syzbot+213ac8bb98f7f4420840@syzkaller.appspotmail.com Tested-by: syzbot+213ac8bb98f7f4420840@syzkaller.appspotmail.com Acked-by: Anton Altaparmakov <anton@tuxera.com> Cc: Shuah Khan <skhan@linuxfoundation.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c1c9142 commit d98e4d9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/ntfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static int ntfs_is_extended_system_file(ntfs_attr_search_ctx *ctx)
477477
}
478478
file_name_attr = (FILE_NAME_ATTR*)((u8*)attr +
479479
le16_to_cpu(attr->data.resident.value_offset));
480-
p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length);
480+
p2 = (u8 *)file_name_attr + le32_to_cpu(attr->data.resident.value_length);
481481
if (p2 < (u8*)attr || p2 > p)
482482
goto err_corrupt_attr;
483483
/* This attribute is ok, but is it in the $Extend directory? */

0 commit comments

Comments
 (0)