From: Stephen Rothwell <sfr@canb.auug.org.au>
To: jim.houston@attbi.com
Cc: md@Linux.IT, julie.n.fleischer@intel.com,
linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: Re: 2.5.51 nanosleep fails
Date: Fri, 13 Dec 2002 12:29:04 +1100 [thread overview]
Message-ID: <20021213122904.5e3208bf.sfr@canb.auug.org.au> (raw)
In-Reply-To: <200212122227.gBCMRkT10652@linux.local>
Hi All,
On Thu, 12 Dec 2002 17:27:46 -0500 Jim Houston <jim.houston@attbi.com> wrote:
>
> 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.
Equivalent fix for the compatibility layer ...
Not compiled, not tested (I need to get a 64 bit machine ...)
Obviously correct (hopefully) :-)
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
diff -ruN 2.5.51/kernel/compat.c 2.5.51-ns/kernel/compat.c
--- 2.5.51/kernel/compat.c 2002-12-10 15:10:41.000000000 +1100
+++ 2.5.51-ns/kernel/compat.c 2002-12-13 12:12:00.000000000 +1100
@@ -21,8 +21,7 @@
static long compat_nanosleep_restart(struct restart_block *restart)
{
unsigned long expire = restart->arg0, now = jiffies;
- struct timespec *rmtp = (struct timespec *) restart->arg1;
- long ret;
+ struct compat_timespec *rmtp;
/* Did it expire while we handled signals? */
if (!time_after(expire, now))
@@ -30,22 +29,22 @@
current->state = TASK_INTERRUPTIBLE;
expire = schedule_timeout(expire - now);
+ if (expire == 0)
+ return 0;
- ret = 0;
- if (expire) {
+ rmtp = (struct compat_timespec *)restart->arg1;
+ if (rmtp) {
struct compat_timespec ct;
struct timespec t;
jiffies_to_timespec(expire, &t);
ct.tv_sec = t.tv_sec;
ct.tv_nsec = t.tv_nsec;
-
- ret = -ERESTART_RESTARTBLOCK;
if (copy_to_user(rmtp, &ct, sizeof(ct)))
- ret = -EFAULT;
- /* The 'restart' block is already filled in */
+ return -EFAULT;
}
- return ret;
+ /* The 'restart' block is already filled in */
+ return -ERESTART_RESTARTBLOCK;
}
asmlinkage long compat_sys_nanosleep(struct compat_timespec *rqtp,
@@ -53,8 +52,8 @@
{
struct compat_timespec ct;
struct timespec t;
+ struct restart_block *restart;
unsigned long expire;
- s32 ret;
if (copy_from_user(&ct, rqtp, sizeof(ct)))
return -EFAULT;
@@ -67,25 +66,21 @@
expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
current->state = TASK_INTERRUPTIBLE;
expire = schedule_timeout(expire);
+ if (expire == 0)
+ return 0;
- ret = 0;
- if (expire) {
- struct restart_block *restart;
-
+ if (rmtp) {
jiffies_to_timespec(expire, &t);
ct.tv_sec = t.tv_sec;
ct.tv_nsec = t.tv_nsec;
-
if (copy_to_user(rmtp, &ct, sizeof(ct)))
return -EFAULT;
-
- restart = ¤t_thread_info()->restart_block;
- restart->fn = compat_nanosleep_restart;
- restart->arg0 = jiffies + expire;
- restart->arg1 = (unsigned long) rmtp;
- ret = -ERESTART_RESTARTBLOCK;
}
- return ret;
+ restart = ¤t_thread_info()->restart_block;
+ restart->fn = compat_nanosleep_restart;
+ restart->arg0 = jiffies + expire;
+ restart->arg1 = (unsigned long) rmtp;
+ return -ERESTART_RESTARTBLOCK;
}
/*
next prev parent reply other threads:[~2002-12-13 1:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-12 22:27 Jim Houston
2002-12-13 1:29 ` Stephen Rothwell [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-12-12 19:59 Fleischer, Julie N
2002-12-11 21:05 Jim Houston
2002-12-12 20:57 ` Marco d'Itri
2002-12-10 23:57 Marco d'Itri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021213122904.5e3208bf.sfr@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=jim.houston@attbi.com \
--cc=julie.n.fleischer@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=md@Linux.IT \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®