Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.25-rc7 /kernel/compat.c

Filename:/kernel/compat.c
Lines Added:39
Lines Deleted:4
Also changed in: (Previous) 2.6.25-rc6  2.6.25-rc5  2.6.25-rc4  2.6.25-rc3  2.6.25-rc2  2.6.25-rc1 
(Following) 2.6.25-rc8  2.6.25-rc9  2.6.25  2.6.25-git1  2.6.25-git2  2.6.25-git3 

Location
[  2.6.25-rc7
  [  kernel
     o  compat.c

Patch

diff --git a/kernel/compat.c b/kernel/compat.c
index 42a1ed4..5f0e201 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -40,10 +40,35 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user
          __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
 }
 
+static long compat_nanosleep_restart(struct restart_block *restart)
+{
+   struct compat_timespec __user *rmtp;
+   struct timespec rmt;
+   mm_segment_t oldfs;
+   long ret;
+
+   rmtp = (struct compat_timespec __user *)(restart->arg1);
+   restart->arg1 = (unsigned long)&rmt;
+   oldfs = get_fs();
+   set_fs(KERNEL_DS);
+   ret = hrtimer_nanosleep_restart(restart);
+   set_fs(oldfs);
+
+   if (ret) {
+      restart->arg1 = (unsigned long)rmtp;
+
+      if (rmtp && put_compat_timespec(&rmt, rmtp))
+         return -EFAULT;
+   }
+
+   return ret;
+}
+
 asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
                  struct compat_timespec __user *rmtp)
 {
    struct timespec tu, rmt;
+   mm_segment_t oldfs;
    long ret;
 
    if (get_compat_timespec(&tu, rqtp))
@@ -52,11 +77,21 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
    if (!timespec_valid(&tu))
       return -EINVAL;
 
-   ret = hrtimer_nanosleep(&tu, rmtp ? &rmt : NULL, HRTIMER_MODE_REL,
-            CLOCK_MONOTONIC);
+   oldfs = get_fs();
+   set_fs(KERNEL_DS);
+   ret = hrtimer_nanosleep(&tu,
+            rmtp ? (struct timespec __user *)&rmt : NULL,
+            HRTIMER_MODE_REL, CLOCK_MONOTONIC);
+   set_fs(oldfs);
+
+   if (ret) {
+      struct restart_block *restart
+         = ¤t_thread_info()->restart_block;
+
+      restart->fn = compat_nanosleep_restart;
+      restart->arg1 = (unsigned long)rmtp;
 
-   if (ret && rmtp) {
-      if (put_compat_timespec(&rmt, rmtp))
+      if (rmtp && put_compat_timespec(&rmt, rmtp))
          return -EFAULT;
    }
 


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.