Skip to contentSkip to conversation

fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext

PATCH In review Konstantin Komarov 2 participants 2 messages Sep 9, 2021

Subsystems (2)
lore
Share & tools
lore

Konstantin Komarov

author maintainer
#0 lore raw

PATCH 1/3 fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext

Do not try to insert attribute if there is no room in record.

---
 fs/ntfs3/frecord.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ntfs3/frecord.c +4 -0
index 938b12d56ca6..5dd7b7a7c5e0 100644
@@ -956,6 +956,10 @@ 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);
Signature · 1 line
2.28.0
#1 lore raw
Quoted 12 lines · Konstantin Komarov

Do not try to insert attribute if there is no room in record.

---
 fs/ntfs3/frecord.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/ntfs3/frecord.c +0 -0
index 938b12d56ca6..5dd7b7a7c5e0 100644

fs/ntfs3/frecord.c static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le, · line 959

Quoted 4 lines
fs/ntfs3/frecord.c +1 -0
@@ -956,6 +956,10 @@ 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. */

Multiline comment as this gets very long.

Quoted 8 lines
fs/ntfs3/frecord.c +3 -0
+		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);
Signature · 1 line
2.28.0