Skip to content

Commit 5be79de

Browse files
author
Tyler Hicks
committed
eCryptfs: Flush dirty pages in setattr
After 57db4e8 changed eCryptfs to write-back caching, eCryptfs page writeback updates the lower inode times due to the use of vfs_write() on the lower file. To preserve inode metadata changes, such as 'cp -p' does with utimensat(), we need to flush all dirty pages early in ecryptfs_setattr() so that the user-updated lower inode metadata isn't clobbered later in writeback. https://bugzilla.kernel.org/show_bug.cgi?id=33372 Reported-by: Rocko <[email protected]> Signed-off-by: Tyler Hicks <[email protected]>
1 parent 3aeb86e commit 5be79de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/ecryptfs/inode.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,12 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
929929
}
930930
}
931931
mutex_unlock(&crypt_stat->cs_mutex);
932+
if (S_ISREG(inode->i_mode)) {
933+
rc = filemap_write_and_wait(inode->i_mapping);
934+
if (rc)
935+
goto out;
936+
fsstack_copy_attr_all(inode, lower_inode);
937+
}
932938
memcpy(&lower_ia, ia, sizeof(lower_ia));
933939
if (ia->ia_valid & ATTR_FILE)
934940
lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);

0 commit comments

Comments
 (0)