X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=fs%2Futimes.c;h=b9912ecbee241231ca0b776d9131af1e2643d80a;hb=6fce7fcd6d062f7acb423c5d6a190f2977454640;hp=83a7e69e706caeaf576616eeae53d6d5bcfadac6;hpb=489de30259e667d7bc47da9da44a0270b050cd97;p=deliverable%2Flinux.git diff --git a/fs/utimes.c b/fs/utimes.c index 83a7e69e706c..b9912ecbee24 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -38,6 +38,14 @@ asmlinkage long sys_utime(char __user *filename, struct utimbuf __user *times) #endif +static bool nsec_valid(long nsec) +{ + if (nsec == UTIME_OMIT || nsec == UTIME_NOW) + return true; + + return nsec >= 0 && nsec <= 999999999; +} + /* If times==NULL, set access and modification to current time, * must be owner or have write permission. * Else, update from *times, must be owner or super user. @@ -52,6 +60,11 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags struct file *f = NULL; error = -EINVAL; + if (times && (!nsec_valid(times[0].tv_nsec) || + !nsec_valid(times[1].tv_nsec))) { + goto out; + } + if (flags & ~AT_SYMLINK_NOFOLLOW) goto out; @@ -106,7 +119,7 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags if (IS_IMMUTABLE(inode)) goto dput_and_out; - if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) { + if (!is_owner_or_cap(inode)) { if (f) { if (!(f->f_mode & FMODE_WRITE)) goto dput_and_out;