fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Wed, 8 Sep 2021 15:39:53 +0000 (18:39 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 21 Sep 2021 15:36:40 +0000 (18:36 +0300)
Do not try to insert attribute if there is no room in record.

Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/frecord.c

index 1e1a090..0d00b23 100644 (file)
@@ -953,6 +953,13 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
                        continue;
                }
 
+               /*
+                * Do not try to insert this attribute
+                * if there is no room in record.
+                */
+               if (le32_to_cpu(mi->mrec->used) + asize > sbi->record_size)
+                       continue;
+
                /* Try to insert attribute into this subrecord. */
                attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
                                       name_off, svcn, ins_le);