]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Add sanity check for file name
authorLizhi Xu <lizhi.xu@windriver.com>
Fri, 6 Jun 2025 05:16:16 +0000 (13:16 +0800)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 23 Jun 2025 17:23:03 +0000 (19:23 +0200)
The length of the file name should be smaller than the directory entry size.

Reported-by: syzbot+598057afa0f49e62bd23@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=598057afa0f49e62bd23
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/dir.c

index 4aab4d54b1715a52c822ba6ea8f9f5280a380dfd..1b5c865a0339a102a9e0b99a1f26e89b6203855a 100644 (file)
@@ -304,6 +304,9 @@ static inline bool ntfs_dir_emit(struct ntfs_sb_info *sbi,
        if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
                return true;
 
+       if (fname->name_len + sizeof(struct NTFS_DE) > le16_to_cpu(e->size))
+               return true;
+
        name_len = ntfs_utf16_to_nls(sbi, fname->name, fname->name_len, name,
                                     PATH_MAX);
        if (name_len <= 0) {