Re: [PATCH v1 2/9] ntfs: fail EA update when reading $EA_INFORMATION fails
From: Hyunchul Lee
Date: Mon Aug 24 2026 - 01:09:17 EST
2026년 8월 21일 (금) 오후 2:33, Baolin Liu <liubaolin12138@xxxxxxx>님이 작성:
>
> From: Baolin Liu <liubaolin@xxxxxxxxxx>
>
> In ntfs_set_ea(), when the $EA_INFORMATION attribute exists but
> reading it fails or returns an unexpected size, the function jumps
> to the exit label with err still 0, so setxattr(2) reports success
> without writing anything.
>
> Worse, ea_info_qsize is still 0 at that point, so the exit path
> calls NInoClearHasEA() on an inode that does have EAs on disk,
> hiding all existing EAs until the inode is evicted.
>
> Return -EIO in this case and leave the HasEA flag untouched on
> failure.
>
> Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
> Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>
> ---
> fs/ntfs/ea.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index 59e5e86e38e3..10d5b192f07e 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -208,8 +208,10 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
> if (ntfs_attr_exist(ni, AT_EA_INFORMATION, AT_UNNAMED, 0)) {
> p_ea_info = ntfs_attr_readall(ni, AT_EA_INFORMATION, NULL, 0,
> &ea_info_size);
> - if (!p_ea_info || ea_info_size != sizeof(struct ea_information))
> + if (!p_ea_info || ea_info_size != sizeof(struct ea_information)) {
> + err = -EIO;
> goto out;
> + }
>
> ea_buf = ntfs_attr_readall(ni, AT_EA, NULL, 0, &all_ea_size);
> if (!ea_buf) {
> @@ -390,10 +392,12 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
> *packed_ea_size = p_ea_info->ea_length;
> mark_mft_record_dirty(ni);
> out:
> - if (ea_info_qsize > 0)
> - NInoSetHasEA(ni);
> - else
> - NInoClearHasEA(ni);
> + if (!err) {
> + if (ea_info_qsize > 0)
> + NInoSetHasEA(ni);
> + else
> + NInoClearHasEA(ni);
> + }
>
> kvfree(ea_buf);
> kvfree(old_ea_buf);
> --
> 2.51.0
>
>
--
Thanks,
Hyunchul