Re: [PATCH v3 2/4] ntfs: protect attribute-list buffer replacement with attr_list_persist_lock

Namjae Jeon <[email protected]> Wed, 29 Jul 2026 19:10:50 +0900
Newsgroups dev.linux.lists.ntfs
Message-ID <CAKYAXd_WQ62btrrAqhFE6QocbWhs5FNs3xVWPpgj_=VvroaVmg@mail.gmail.com>
> diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
> index a99c228184ce..ee7e5ec6ade4 100644
> --- a/fs/ntfs/inode.h
> +++ b/fs/ntfs/inode.h
> @@ -69,6 +69,7 @@ enum ntfs_inode_mutex_lock_class {
>   * functions). Setup during read_inode for all inodes with attribute
>   * lists. Only valid if NI_AttrList is set in state.
>   * @attr_list_lock: Protects in-memory attribute list state.
> + * @attr_list_persist_lock: Serializes attribute list replacement and persist.
>   * @attr_list_gen: Generation of the in-memory attribute list state.
>   * @attr_list_size: Length of attribute list value in bytes.
>   * @attr_list: Attribute list value itself.
> @@ -123,6 +124,8 @@ struct ntfs_inode {
>         s64 mft_lcn[2];
>         unsigned int mft_lcn_count;
>         struct rw_semaphore attr_list_lock;
> +       /* Serializes attribute list replacement and persist. */
> +       struct mutex attr_list_persist_lock;
The new mutex covers ntfs_attrlist_entry_add() and
ntfs_attrlist_entry_rm(), but existing paths still call
ntfs_attrlist_update() without holding it.