]> git.neil.brown.name Git - history.git/commitdiff
Fix posix timer direct user space access
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 20 Oct 2004 10:44:41 +0000 (03:44 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 20 Oct 2004 10:44:41 +0000 (03:44 -0700)
This makes us do the proper copy_to_user() for the new
posix timers code.

Acked by Christoph Lameter <clameter@sgi.com>.

kernel/posix-timers.c

index 4a3f7cd9bfdc188e2224081edd4e9b3ab1abb67a..51be7de8adc1a90e62fdaf68b6241b85256e4fa8 100644 (file)
@@ -1326,12 +1326,8 @@ sys_clock_settime(clockid_t which_clock, const struct timespec __user *tp)
        return do_sys_settimeofday(&new_tp, NULL);
 }
 
-asmlinkage long
-sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
+static int do_clock_gettime(clockid_t which_clock, struct timespec *tp)
 {
-       struct timespec rtn_tp;
-       int error = 0;
-
        /* Process process specific clocks */
        if (which_clock < 0) {
                task_t *t;
@@ -1359,9 +1355,17 @@ sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
                                        !posix_clocks[which_clock].res)
                return -EINVAL;
 
-       error = do_posix_gettime(&posix_clocks[which_clock], &rtn_tp);
+       return do_posix_gettime(&posix_clocks[which_clock], tp);
+}
+
+asmlinkage long
+sys_clock_gettime(clockid_t which_clock, struct timespec __user *tp)
+{
+       struct timespec kernel_tp;
+       int error;
 
-       if (!error && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
+       error = do_clock_gettime(which_clock, &kernel_tp);
+       if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp)))
                error = -EFAULT;
 
        return error;