summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAbdun Nihaal <abdun.nihaal@gmail.com>2022-10-04 08:45:02 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-09 11:28:26 +0100
commit543bba3be262803c13678401a925e45003f26e7a (patch)
tree7c52cdf3fbe0a61b51e52bba773c2cb36afdc0a8 /fs
parent0153009a7e6500bec259ac1d2dabf64aa6aef616 (diff)
downloadlinux-stable-543bba3be262803c13678401a925e45003f26e7a.tar.gz
linux-stable-543bba3be262803c13678401a925e45003f26e7a.tar.bz2
linux-stable-543bba3be262803c13678401a925e45003f26e7a.zip
fs/ntfs3: Validate attribute data and valid sizes
commit 019d22eb0eb707fc099e6e8fad9b3933236a06d0 upstream. The data_size and valid_size fields of non resident attributes should be less than the its alloc_size field, but this is not checked in ntfs_read_mft function. Syzbot reports a allocation order warning due to a large unchecked value of data_size getting assigned to inode->i_size which is then passed to kcalloc. Add sanity check for ensuring that the data_size and valid_size fields are not larger than alloc_size field. Link: https://syzkaller.appspot.com/bug?extid=fa4648a5446460b7b963 Reported-and-tested-by: syzbot+fa4648a5446460b7b963@syzkaller.appspotmail.com Fixes: (82cae269cfa95) fs/ntfs3: Add initialization of super block Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ntfs3/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index e352aa37330c..22152300e60c 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -132,6 +132,13 @@ next_attr:
if (le16_to_cpu(attr->name_off) + attr->name_len > asize)
goto out;
+ if (attr->non_res) {
+ t64 = le64_to_cpu(attr->nres.alloc_size);
+ if (le64_to_cpu(attr->nres.data_size) > t64 ||
+ le64_to_cpu(attr->nres.valid_size) > t64)
+ goto out;
+ }
+
switch (attr->type) {
case ATTR_STD:
if (attr->non_res ||