mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
utimes: Clamp the timestamps in notify_change()
Push clamping timestamps into notify_change(), so in-kernel
callers like nfsd and overlayfs will get similar timestamp
set behavior as utimes.
AV: get rid of clamping in ->setattr() instances; we don't need
to bother with that there, with notify_change() doing normalization
in all cases now (it already did for implicit case, since current_time()
clamps).
Suggested-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 42e729b9dd
("utimes: Clamp the timestamps before update")
Cc: stable@vger.kernel.org # v5.4
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
23
fs/attr.c
23
fs/attr.c
@@ -183,18 +183,12 @@ void setattr_copy(struct inode *inode, const struct iattr *attr)
|
||||
inode->i_uid = attr->ia_uid;
|
||||
if (ia_valid & ATTR_GID)
|
||||
inode->i_gid = attr->ia_gid;
|
||||
if (ia_valid & ATTR_ATIME) {
|
||||
inode->i_atime = timestamp_truncate(attr->ia_atime,
|
||||
inode);
|
||||
}
|
||||
if (ia_valid & ATTR_MTIME) {
|
||||
inode->i_mtime = timestamp_truncate(attr->ia_mtime,
|
||||
inode);
|
||||
}
|
||||
if (ia_valid & ATTR_CTIME) {
|
||||
inode->i_ctime = timestamp_truncate(attr->ia_ctime,
|
||||
inode);
|
||||
}
|
||||
if (ia_valid & ATTR_ATIME)
|
||||
inode->i_atime = attr->ia_atime;
|
||||
if (ia_valid & ATTR_MTIME)
|
||||
inode->i_mtime = attr->ia_mtime;
|
||||
if (ia_valid & ATTR_CTIME)
|
||||
inode->i_ctime = attr->ia_ctime;
|
||||
if (ia_valid & ATTR_MODE) {
|
||||
umode_t mode = attr->ia_mode;
|
||||
|
||||
@@ -268,8 +262,13 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
|
||||
attr->ia_ctime = now;
|
||||
if (!(ia_valid & ATTR_ATIME_SET))
|
||||
attr->ia_atime = now;
|
||||
else
|
||||
attr->ia_atime = timestamp_truncate(attr->ia_atime, inode);
|
||||
if (!(ia_valid & ATTR_MTIME_SET))
|
||||
attr->ia_mtime = now;
|
||||
else
|
||||
attr->ia_mtime = timestamp_truncate(attr->ia_mtime, inode);
|
||||
|
||||
if (ia_valid & ATTR_KILL_PRIV) {
|
||||
error = security_inode_need_killpriv(dentry);
|
||||
if (error < 0)
|
||||
|
Reference in New Issue
Block a user