[PATCH 3/5] ntfs: preserve the truncate error in ntfs_enlarge_attribute()

From: Baolin Liu

Date: Wed Sep 02 2026 - 03:43:10 EST


From: Baolin Liu <liubaolin@xxxxxxxxxx>

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: af0db57d4293 ("ntfs: update inode operations")
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
fs/ntfs/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 747a60ae27c9..9b2ff15da94c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -3618,9 +3618,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);
--
2.51.0