Re: 2.5.51 nanosleep fails

Jim Houston
2002-12-12T22:21:06Z

Hi Linus, Marco, Julie, Everyone,

It really is broken. I just didn't try enough combinations.

Thanks Julie, the test suite really helps.

The problem is that nanosleep didn't check for the NULL pointer
case and always tries to copy out the remaining time. The attached
patch will fix this problem.

Jim Houston - Concurrent Computer Corp.

--- linux-2.5.51.orig/kernel/timer.c Thu Dec 12 17:08:30 2002
+++ linux-2.5.51.new/kernel/timer.c Thu Dec 12 16:59:10 2002
@@ -1040,7 +1040,7 @@
jiffies_to_timespec(expire, &t);

ret = -ERESTART_RESTARTBLOCK;
- if (copy_to_user(rmtp, &t, sizeof(t)))
+ if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
ret = -EFAULT;
/* The 'restart' block is already filled in */
}
@@ -1067,7 +1067,7 @@
if (expire) {
struct restart_block *restart;
jiffies_to_timespec(expire, &t);
- if (copy_to_user(rmtp, &t, sizeof(t)))
+ if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
return -EFAULT;

restart = &current_thread_info()->restart_block;