On Tuesday 19 May 2015 20:49:49 Baolin Wang wrote:
+/* Set a POSIX.1b interval timer */ +SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
const struct itimerspec __user *, new_setting,
struct itimerspec __user *, old_setting)
+{
struct itimerspec new_spec, old_spec;
int error = 0;
struct itimerspec *rtn = old_setting ? &old_spec : NULL;
if (!new_setting)
return -EINVAL;
if (copy_from_user(&new_spec, new_setting, sizeof (new_spec)))
return -EFAULT;
if (!timespec_valid(&new_spec.it_interval) ||
!timespec_valid(&new_spec.it_value))
return -EINVAL;
error = __timer_settime(timer_id, flags, &new_spec, rtn);
if (old_setting && !error && copy_to_user(old_setting, &old_spec, sizeof (old_spec))) error = -EFAULT;
This part currently conflicts with my patch series that does the same thing slightly differently.
That is not a problem by itself, but it means that we have to coordinate a bit. One of us needs to get his patches merged first, so that the other one can rebase the other patches on top.
My patch for this is currently in drafting state, so it's possible that you should just go first, but please have a look at my implementation at http://git.kernel.org/cgit/linux/kernel/git/arnd/playground.git/commit/?h=y2...
I'm currently using a get_itimerspec() function there that copies a user space __kernel_itimerspec into a kernel-side itimerspec. There is also a get_timespec64() function I introduce, and in combination with your series, we should have a get_itimerspec64() as well as get_compat_itimerspec64() function.
I did not integrate the timespec_valid() part in there, but after looking at your code some more, I now think it would be good to combine them and have something like:
int get_itimerspec64(struct itimerspec64 *it, const struct __kernel_itimerspec __user *uit) { int ret
ret = get_timespec64(&it->it_interval, &uit->it_interval); if (ret) return ret;
return get_timespec64(&it->it_value, &uit->it_value); }
and add the timespec64_valid() check to get_timespec64().
Arnd