2021-09-13 15:14:48

by Konstantin Komarov

[permalink] [raw]
Subject: [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.

Signed-off-by: Konstantin Komarov <[email protected]>
---
fs/ntfs3/frecord.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 938b12d56ca6..834cb361f61f 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -956,6 +956,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);
--
2.33.0


2021-09-18 13:32:21

by Kari Argillander

[permalink] [raw]
Subject: Re: [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext

On Mon, Sep 13, 2021 at 06:12:58PM +0300, Konstantin Komarov wrote:
> Do not try to insert attribute if there is no room in record.
>
> Signed-off-by: Konstantin Komarov <[email protected]>

Reviewed-by: Kari Argillander <[email protected]>

> ---
> fs/ntfs3/frecord.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 938b12d56ca6..834cb361f61f 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -956,6 +956,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);
> --
> 2.33.0
>
>