From: Lizhi Xu Date: Fri, 6 Jun 2025 05:16:16 +0000 (+0800) Subject: fs/ntfs3: Add sanity check for file name X-Git-Tag: v6.16.2~452 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27ee9a42b245efe6529e28b03453291a775cb3e4;p=thirdparty%2Fkernel%2Fstable.git fs/ntfs3: Add sanity check for file name [ Upstream commit e841ecb139339602bc1853f5f09daa5d1ea920a2 ] 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 Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index b6da80c69ca63..600e66035c1b7 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -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) {