summaryrefslogtreecommitdiff
path: root/fs/attr.c
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-10-24 00:01:43 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-10-24 00:01:43 -0300
commit037d32aa8f748e39844d2a5b607fb063b4583843 (patch)
treeb5fe973d42017b5d8888103b05be7a503fe95f0f /fs/attr.c
parent670027c507e99521d416994a18a498def9ef2ea3 (diff)
Linux-libre 4.8.4-gnupck-4.8.4-gnu
Diffstat (limited to 'fs/attr.c')
-rw-r--r--fs/attr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/attr.c b/fs/attr.c
index 42bb42bb3..3c42cab06 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -202,6 +202,21 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
return -EPERM;
}
+ /*
+ * If utimes(2) and friends are called with times == NULL (or both
+ * times are UTIME_NOW), then we need to check for write permission
+ */
+ if (ia_valid & ATTR_TOUCH) {
+ if (IS_IMMUTABLE(inode))
+ return -EPERM;
+
+ if (!inode_owner_or_capable(inode)) {
+ error = inode_permission(inode, MAY_WRITE);
+ if (error)
+ return error;
+ }
+ }
+
if ((ia_valid & ATTR_MODE)) {
umode_t amode = attr->ia_mode;
/* Flag setting protected by i_mutex */