diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2007-10-17 02:27:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:52 -0400 |
commit | 043f46f6151df2c518988b5e41376e42491257b5 (patch) | |
tree | 036f75b27d139408da721aaa75ed41a9b737a83d /fs | |
parent | 995e4286a047b32aebf8ce540908edb7fbd93f76 (diff) |
VFS: check nanoseconds in utimensat
utimensat() (and possibly other callers of do_utimes()) didn't check if the
nanosecond value was within the allowed range.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/utimes.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/utimes.c b/fs/utimes.c index 682eb63b20ad..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) | |||
38 | 38 | ||
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | static bool nsec_valid(long nsec) | ||
42 | { | ||
43 | if (nsec == UTIME_OMIT || nsec == UTIME_NOW) | ||
44 | return true; | ||
45 | |||
46 | return nsec >= 0 && nsec <= 999999999; | ||
47 | } | ||
48 | |||
41 | /* If times==NULL, set access and modification to current time, | 49 | /* If times==NULL, set access and modification to current time, |
42 | * must be owner or have write permission. | 50 | * must be owner or have write permission. |
43 | * Else, update from *times, must be owner or super user. | 51 | * 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 | |||
52 | struct file *f = NULL; | 60 | struct file *f = NULL; |
53 | 61 | ||
54 | error = -EINVAL; | 62 | error = -EINVAL; |
63 | if (times && (!nsec_valid(times[0].tv_nsec) || | ||
64 | !nsec_valid(times[1].tv_nsec))) { | ||
65 | goto out; | ||
66 | } | ||
67 | |||
55 | if (flags & ~AT_SYMLINK_NOFOLLOW) | 68 | if (flags & ~AT_SYMLINK_NOFOLLOW) |
56 | goto out; | 69 | goto out; |
57 | 70 | ||