|
@@ -40,9 +40,14 @@ asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
+static bool nsec_special(long nsec)
|
|
|
+{
|
|
|
+ return nsec == UTIME_OMIT || nsec == UTIME_NOW;
|
|
|
+}
|
|
|
+
|
|
|
static bool nsec_valid(long nsec)
|
|
|
{
|
|
|
- if (nsec == UTIME_OMIT || nsec == UTIME_NOW)
|
|
|
+ if (nsec_special(nsec))
|
|
|
return true;
|
|
|
|
|
|
return nsec >= 0 && nsec <= 999999999;
|
|
@@ -119,7 +124,15 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
|
|
|
newattrs.ia_mtime.tv_nsec = times[1].tv_nsec;
|
|
|
newattrs.ia_valid |= ATTR_MTIME_SET;
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * If times is NULL or both times are either UTIME_OMIT or
|
|
|
+ * UTIME_NOW, then need to check permissions, because
|
|
|
+ * inode_change_ok() won't do it.
|
|
|
+ */
|
|
|
+ if (!times || (nsec_special(times[0].tv_nsec) &&
|
|
|
+ nsec_special(times[1].tv_nsec))) {
|
|
|
error = -EACCES;
|
|
|
if (IS_IMMUTABLE(inode))
|
|
|
goto mnt_drop_write_and_out;
|