simple_link() and __simple_unlink() copy the child's new ctime into the parent directory. With multigrain timestamps that ctime is only fine-grained if the child was queried and copying it drops the parent's I_CTIME_QUERIED flag. So a queried tmpfs directory keeps its ctime and mtime across link(), unlink() and rmdir() as long as the coarse clock hasn't ticked. shmem_rename2() unlinks the victim of a rename the same way, so a rename over an entry from another directory changes nothing at all that userspace could see, size and link count included. Give the directory its own inode_set_ctime_current() call. Fixes: 234d8895e3ad ("tmpfs: add support for multigrain timestamps") Cc: stable@vger.kernel.org # v6.13+ Signed-off-by: Christian Brauner (Amutable) --- fs/libfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 96a6e9b1535fb..07331e829c133 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -754,8 +754,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den { struct inode *inode = d_inode(old_dentry); - inode_set_mtime_to_ts(dir, - inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode))); + inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); + inode_set_ctime_current(inode); inc_nlink(inode); ihold(inode); d_make_persistent(dentry, inode); @@ -788,8 +788,8 @@ void __simple_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode = d_inode(dentry); - inode_set_mtime_to_ts(dir, - inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode))); + inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); + inode_set_ctime_current(inode); drop_nlink(inode); } EXPORT_SYMBOL(__simple_unlink); -- 2.53.0