Commit 73a9eb39 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] settimeofday() fixes

From: davem

- sys_stime() takes an int*, but it should be a time_t*: they have different
  sizes on (for example) sparc64.

- sys_settimeofday() is confusing timevals with timespecs.  They have
  different sizes on sparc64 and the time keeps on getting set to epoch.
parent 5808e76e
......@@ -66,7 +66,7 @@ asmlinkage long sys_time(int * tloc)
* architectures that need it).
*/
asmlinkage long sys_stime(int * tptr)
asmlinkage long sys_stime(time_t *tptr)
{
struct timespec tv;
......@@ -160,22 +160,25 @@ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
return 0;
}
asmlinkage long sys_settimeofday(struct timeval __user *tv, struct timezone __user *tz)
asmlinkage long sys_settimeofday(struct timeval __user *tv,
struct timezone __user *tz)
{
struct timespec new_tv;
struct timeval user_tv;
struct timespec new_ts;
struct timezone new_tz;
if (tv) {
if (copy_from_user(&new_tv, tv, sizeof(*tv)))
if (copy_from_user(&user_tv, tv, sizeof(*tv)))
return -EFAULT;
new_tv.tv_nsec *= NSEC_PER_USEC;
new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
}
if (tz) {
if (copy_from_user(&new_tz, tz, sizeof(*tz)))
return -EFAULT;
}
return do_sys_settimeofday(tv ? &new_tv : NULL, tz ? &new_tz : NULL);
return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
}
long pps_offset; /* pps time offset (us) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment