overlayfs: set ctime when setting mtime and atime
Subsystems (2)
PATCH 1/1 overlayfs: set ctime when setting mtime and atime
Nathan reported that he was seeing the new warning in setattr_copy_mgtime pop when starting podman containers. Overlayfs is trying to set the atime and mtime via notify_change without also setting the ctime.
POSIX states that when the atime and mtime are updated via utimes() that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so add ATTR_CTIME to the bitmask. notify_change will fill in the value.
---
The new WARN_ON_ONCE in setattr_copy_mgtime caught a bug! Fix up overlayfs to ensure that the ctime on the upper inode is also updated when copying up the atime and mtime.
--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/copy_up.c +1 -1
@@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, {struct iattr attr = { .ia_valid = -ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET , +ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_CTIME , .ia_atime = stat->atime, .ia_mtime = stat->mtime, };
---
base-commit: 9cb8e7c86ac793862e7bea7904b3426942bbd7ef
change-id: 20230913-ctime-299173760dd9
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 8 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.
Bah...make that "analogous".
Quoted 31 lines
notify_changewill fill in the value.Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
The newWARN_ON_ONCEinsetattr_copy_mgtimecaught a bug! Fix up overlayfs to ensure that the ctime on the upper inode is also updated when copying up the atime and mtime.--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/overlayfs/copy_up.c +1
-2@@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, {struct iattr attr = { .ia_valid = -ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET , +ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_CTIME , .ia_atime = stat->atime, .ia_mtime = stat->mtime, }; ---base-commit:
9cb8e7c86ac793862e7bea7904b3426942bbd7ef
change-id: 20230913-ctime-299173760dd9Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 5 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.
Quoted 8 lines
POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
Looks good to me,
So we can wait for ovl to upstream this fix next and then we'll delay sending the ctime fixes or we'll take this fixup as well. Just let me know what you all prefer.
Quoted 15 lines · Christian Brauner
Quoted 5 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.Quoted 8 lines
POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
Quoted 6 lines
Looks good to me,
So we can wait for ovl to upstream this fix next and then we'll delay sending the ctime fixes or we'll take this fixup as well. Just let me know what you all prefer.
No preference here.
Signature · 1 line
Jeff Layton <[email protected]>
Amir Goldstein
maintainerQuoted 11 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogous, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.
IDGI, if ctime always needs to be set along with ATIME / MTIME, why not let notify_change() set the bit instead of assert and fix all the callers? But maybe I am missing something.
Anyway, I have no objection to the ovl patch.
It's fine by me if Christian applies it to the vfs.ctime branch with my ACK.
Thanks,
Amir.
Quoted 32 lines
Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
The newWARN_ON_ONCEinsetattr_copy_mgtimecaught a bug! Fix up overlayfs to ensure that the ctime on the upper inode is also updated when copying up the atime and mtime.--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/overlayfs/copy_up.c +1
-2@@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, {struct iattr attr = { .ia_valid = -ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET , +ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_CTIME , .ia_atime = stat->atime, .ia_mtime = stat->mtime, }; ---base-commit:
9cb8e7c86ac793862e7bea7904b3426942bbd7ef
change-id: 20230913-ctime-299173760dd9Best regards,
--
Jeff Layton <[email protected]>
Quoted 13 lines · Amir Goldstein
Quoted 11 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogous, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.
Quoted 4 lines
IDGI, if ctime always needs to be set along with ATIME / MTIME, why not let
notify_change()set the bit instead of assert and fix all the callers? But maybe I am missing something.
Traditionally notify_change has always been given an explicit mask of attrs to change by the caller. I'm a little hesitant to start putting POSIX policy in there.
Still, that may be the better thing to do over the long haul. I think that there are some other bugs in the notify_change callers as well: for instance, cachefiles_adjust_size truncates files, but doesn't update the timestamps. I'm pretty sure that's wrong.
I think if we want to change how setattr ctime updates work, we'll probably need to do it in the context of a larger notify_change overhaul.
Quoted 3 lines
Anyway, I have no objection to the ovl patch.
It's fine by me if Christian applies it to the vfs.ctime branch with my ACK.
Many thanks!
Quoted 35 lines
Thanks,
Amir.Quoted 32 lines
Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
The newWARN_ON_ONCEinsetattr_copy_mgtimecaught a bug! Fix up overlayfs to ensure that the ctime on the upper inode is also updated when copying up the atime and mtime.--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/overlayfs/copy_up.c +1
-2@@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, {struct iattr attr = { .ia_valid = -ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET , +ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_CTIME , .ia_atime = stat->atime, .ia_mtime = stat->mtime, }; ---base-commit:
9cb8e7c86ac793862e7bea7904b3426942bbd7ef
change-id: 20230913-ctime-299173760dd9Best regards,
--
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 5 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.
Quoted 7 lines
POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.Reported-by Nathan Chancellor <[email protected]>Signed-off-by Jeff Layton <[email protected]>
I applied this patch on top of next-20230913 and I do not see the warning I reported on any of my machines. Thanks for the quick fix!
Quoted 30 lines
---
The newWARN_ON_ONCEinsetattr_copy_mgtimecaught a bug! Fix up overlayfs to ensure that the ctime on the upper inode is also updated when copying up the atime and mtime.--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/overlayfs/copy_up.c +1
-2@@ -337,7 +337,7 @@ static int ovl_set_timestamps(struct ovl_fs *ofs, struct dentry *upperdentry, {struct iattr attr = { .ia_valid = -ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET , +ATTR_ATIME |ATTR_MTIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_CTIME , .ia_atime = stat->atime, .ia_mtime = stat->mtime, }; ---base-commit:
9cb8e7c86ac793862e7bea7904b3426942bbd7ef
change-id: 20230913-ctime-299173760dd9Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 11 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.[...]
Applied to the vfs.ctime branch of the vfs/vfs.git tree. Patches in the vfs.ctime branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.ctime
[1/1] overlayfs: set ctime when setting mtime and atime
https://git.kernel.org/vfs/vfs/c/f8edd3368615
Quoted 22 lines · Christian Brauner
Quoted 11 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.[...]
Applied to the vfs.ctime branch of the vfs/vfs.git tree. Patches in the vfs.ctime branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Quoted 8 lines
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.ctime[1/1] overlayfs: set ctime when setting mtime and atime
https://git.kernel.org/vfs/vfs/c/f8edd3368615
Christian, are you still planning to pick up this patch? I saw that it was dropped from linux-next. Since the mgtime patches have been reverted for now, it may be best for this to go in via the overlayfs tree ?
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Amir Goldstein
maintainerQuoted 30 lines · Jeff Layton
Quoted 28 lines · Christian Brauner
Quoted 11 lines · Jeff Layton
Nathan reported that he was seeing the new warning in
setattr_copy_mgtimepop when starting podman containers. Overlayfs is trying to set the atime and mtime vianotify_changewithout also setting the ctime.POSIX states that when the atime and mtime are updated via
utimes()that we must also update the ctime to the current time. The situation with overlayfs copy-up is analogies, so addATTR_CTIMEto the bitmask.notify_changewill fill in the value.[...]
Applied to the vfs.ctime branch of the vfs/vfs.git tree. Patches in the vfs.ctime branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.ctime
Quoted 6 lines
Quoted 2 lines
[1/1] overlayfs: set ctime when setting mtime and atime
https://git.kernel.org/vfs/vfs/c/f8edd3368615Christian, are you still planning to pick up this patch? I saw that it was dropped from linux-next. Since the mgtime patches have been reverted for now, it may be best for this to go in via the overlayfs tree ?
I think this is a long standing overlayfs bug fix, so it should go into 6.6 and not wait for 6.7 anyway.
Also need to add CC stable (don't think we need to bother with Fixes).
I do not have any overlayfs fixes queued ATM.
Christian, if you have any pening VFS fixes, you may send it along with them or we could just ask Linus to apply this one directly, so that any mgtime changes that may still happen for 6.7 will already have this fluke fixed.
Thanks,
Amir.
Christian Brauner
maintainerQuoted 3 lines
Christian, if you have any pening VFS fixes, you may send it along with them or we could just ask Linus to apply this one directly, so that any mgtime changes that may still happen for 6.7 will already have this fluke fixed.
I'll move the fix from vfs.misc into vfs.fixes now and then send it with the pile of other fixes to Linus this week.