Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 98440
b: refs/heads/master
c: 4cca922
h: refs/heads/master
v: v3
  • Loading branch information
Michael Kerrisk authored and Al Viro committed Jun 23, 2008
1 parent ce571c6 commit ccd25e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94c70b9ba7e9c1036284e779e2fef5be89021533
refs/heads/master: 4cca92264e61a90b43fc4e076cd25b7f4e16dc61
36 changes: 21 additions & 15 deletions trunk/fs/utimes.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,9 @@ 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_special(nsec))
if (nsec == UTIME_OMIT || nsec == UTIME_NOW)
return true;

return nsec >= 0 && nsec <= 999999999;
Expand Down Expand Up @@ -106,7 +101,7 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
times[1].tv_nsec == UTIME_NOW)
times = NULL;

/* Don't worry, the checks are done in inode_change_ok() */
/* In most cases, the checks are done in inode_change_ok() */
newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
if (times) {
error = -EPERM;
Expand All @@ -128,15 +123,26 @@ 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;
}
}

/*
* 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))) {
/*
* For the UTIME_OMIT/UTIME_NOW and UTIME_NOW/UTIME_OMIT
* cases, we need to make an extra check that is not done by
* inode_change_ok().
*/
if (((times[0].tv_nsec == UTIME_NOW &&
times[1].tv_nsec == UTIME_OMIT)
||
(times[0].tv_nsec == UTIME_OMIT &&
times[1].tv_nsec == UTIME_NOW))
&& !is_owner_or_cap(inode))
goto mnt_drop_write_and_out;
} else {

/*
* If times is NULL (or both times are UTIME_NOW),
* then we need to check permissions, because
* inode_change_ok() won't do it.
*/
error = -EACCES;
if (IS_IMMUTABLE(inode))
goto mnt_drop_write_and_out;
Expand Down

0 comments on commit ccd25e0

Please sign in to comment.