ntfs: preserve the truncate error in ntfs_enlarge_attribute()

ntfs_enlarge_attribute() discards the error from ntfs_attr_truncate() and
returns -1, which reaches userspace as EPERM. The discarded codes are
meaningful: -ENOSPC when the attribute cannot grow, -EACCES when it is
encrypted, -EOPNOTSUPP when compressed, plus -EINVAL and -ENOMEM.

Most callers of ntfs_inode_attr_pwrite() compare the result against the
requested length and substitute -EIO, masking this. ntfs_ib_write() does
not; it returns the value verbatim, which propagates through
ntfs_index_add_filename() to __ntfs_create() and __ntfs_link(), so a full
volume reports EPERM instead of ENOSPC from create(), mkdir() and link().

Fixes: af0db57d42 ("ntfs: update inode operations")
Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Baolin Liu 2026-09-04 17:00:52 +08:00 committed by Namjae Jeon
parent 41001a72da
commit 5cd6692db2

View File

@ -3629,9 +3629,10 @@ static inline int ntfs_enlarge_attribute(struct inode *vi, s64 pos, s64 count,
return -EOPNOTSUPP;
if (pos + count > ni->data_size) {
if (ntfs_attr_truncate(ni, pos + count)) {
ret = ntfs_attr_truncate(ni, pos + count);
if (ret) {
ntfs_debug("Failed to truncate attribute");
return -1;
return ret;
}
ntfs_attr_reinit_search_ctx(ctx);