[PATCH RESEND] fs/ntfs3: fix valid_size not being updated in attr_allocate_frame()

From: Zhan Xusheng

Date: Fri Sep 04 2026 - 02:29:02 EST


At the end of attr_allocate_frame() the on-disk valid_size is meant to be
updated to the value passed in via @new_valid:

valid_size = le64_to_cpu(attr_b->nres.valid_size);
if (new_valid != valid_size) {
attr_b->nres.valid_size = cpu_to_le64(valid_size);
mi_b->dirty = true;
}

but it writes back the old valid_size that was just read instead of
new_valid, so the field is never actually changed even though the record
is marked dirty -- the intended update is a no-op.

ni_update_parent() spells the same read-compare-write out correctly a few
hundred lines away, storing the newly derived value:

valid_le = cpu_to_le64(new_valid);
if (valid_le != attr->nres.valid_size) {
attr->nres.valid_size = valid_le;

In practice that path, reached from ni_write_inode(), re-derives
nres.valid_size from ni->i_valid on inode write-back, which normally masks
this, so the visible impact is limited. The assignment here is still
wrong though; store @new_valid as intended.

Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
---
No changes; the fix is still needed on v7.3-rc1 and on the ntfs3 devel
branch, which currently points at v7.3-rc1 as well.

v1: https://lore.kernel.org/ntfs3/20260701061451.385659-1-zhanxusheng@xxxxxxxxxx/

fs/ntfs3/attrib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index b1c315206ffa..792838676352 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1995,7 +1995,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,

valid_size = le64_to_cpu(attr_b->nres.valid_size);
if (new_valid != valid_size) {
- attr_b->nres.valid_size = cpu_to_le64(valid_size);
+ attr_b->nres.valid_size = cpu_to_le64(new_valid);
mi_b->dirty = true;
}
}

base-commit: a500db7819c50db59e55f1b4fa1c3baa5a2616f3
--
2.43.0