All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Linus <torvalds@transmeta.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	anton@samba.org, "David S. Miller" <davem@redhat.com>,
	ak@muc.de, davidm@hpl.hp.com, schwidefsky@de.ibm.com,
	ralf@gnu.org, matthew@wil.cx
Subject: [PATCH][COMPAT] {get,put}_compat_timspec 1/8 generic
Date: Wed, 8 Jan 2003 22:37:44 +1100	[thread overview]
Message-ID: <20030108223744.0c4856b7.sfr@canb.auug.org.au> (raw)

Hi Linus,

Andi Kleen asked for these two, so here they are.  This is the generic
part of the patch.  It is relative to 2.5.54 BK.

The diffstat for the total patch is:
 arch/ia64/ia32/ia32_signal.c      |   11 +++-------
 arch/ia64/ia32/sys_ia32.c         |    2 -
 arch/mips64/kernel/linux32.c      |    3 --
 arch/parisc/kernel/sys_parisc32.c |   11 ----------
 arch/ppc64/kernel/signal32.c      |   15 +++-----------
 arch/ppc64/kernel/sys_ppc32.c     |    4 ---
 arch/s390x/kernel/linux32.c       |   11 +++-------
 arch/sparc64/kernel/sys_sparc32.c |    6 +----
 arch/x86_64/ia32/ipc32.c          |    4 ---
 arch/x86_64/ia32/sys_ia32.c       |   40 +++++++++++---------------------------
 include/linux/compat.h            |    2 +
 kernel/compat.c                   |   23 +++++++++++++++------
 12 files changed, 49 insertions(+), 83 deletions(-)

One thing - would these be better as inline functions in linux/compat.h?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.54-200301081106-32bit.2/include/linux/compat.h 2.5.54-200301081106-32bit.3/include/linux/compat.h
--- 2.5.54-200301081106-32bit.2/include/linux/compat.h	2003-01-08 11:41:18.000000000 +1100
+++ 2.5.54-200301081106-32bit.3/include/linux/compat.h	2003-01-08 16:41:48.000000000 +1100
@@ -36,6 +36,8 @@
 extern int cp_compat_stat(struct kstat *, struct compat_stat *);
 extern int get_compat_flock(struct flock *, struct compat_flock *);
 extern int put_compat_flock(struct flock *, struct compat_flock *);
+extern int get_compat_timespec(struct timespec *, struct compat_timespec *);
+extern int put_compat_timespec(struct timespec *, struct compat_timespec *);
 
 #endif /* CONFIG_COMPAT */
 #endif /* _LINUX_COMPAT_H */
diff -ruN 2.5.54-200301081106-32bit.2/kernel/compat.c 2.5.54-200301081106-32bit.3/kernel/compat.c
--- 2.5.54-200301081106-32bit.2/kernel/compat.c	2002-12-16 14:49:55.000000000 +1100
+++ 2.5.54-200301081106-32bit.3/kernel/compat.c	2003-01-08 16:39:44.000000000 +1100
@@ -18,6 +18,20 @@
 
 #include <asm/uaccess.h>
 
+int get_compat_timespec(struct timespec *ts, struct compat_timespec *cts)
+{
+	return (verify_area(VERIFY_READ, cts, sizeof(*cts)) ||
+			__get_user(ts->tv_sec, &cts->tv_sec) ||
+			__get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+
+int put_compat_timespec(struct timespec *ts, struct compat_timespec *cts)
+{
+	return (verify_area(VERIFY_WRITE, cts, sizeof(*cts)) ||
+			__put_user(ts->tv_sec, &cts->tv_sec) ||
+			__put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+
 static long compat_nanosleep_restart(struct restart_block *restart)
 {
 	unsigned long expire = restart->arg0, now = jiffies;
@@ -50,15 +64,12 @@
 asmlinkage long compat_sys_nanosleep(struct compat_timespec *rqtp,
 		struct compat_timespec *rmtp)
 {
-	struct compat_timespec ct;
 	struct timespec t;
 	struct restart_block *restart;
 	unsigned long expire;
 
-	if (copy_from_user(&ct, rqtp, sizeof(ct)))
+	if (get_compat_timespec(&t, rqtp))
 		return -EFAULT;
-	t.tv_sec = ct.tv_sec;
-	t.tv_nsec = ct.tv_nsec;
 
 	if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0))
 		return -EINVAL;
@@ -71,9 +82,7 @@
 
 	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)))
+		if (put_compat_timespec(&t, rmtp))
 			return -EFAULT;
 	}
 	restart = &current_thread_info()->restart_block;

             reply	other threads:[~2003-01-08 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-08 11:37 Stephen Rothwell [this message]
2003-01-08 11:41 ` [PATCH][COMPAT] {get,put}_compat_timspec 2/8 ppc64 Stephen Rothwell
2003-01-08 11:44 ` [PATCH][COMPAT] {get,put}_compat_timspec 3/8 sparc64 Stephen Rothwell
2003-01-08 11:53 ` [PATCH][COMPAT] {get,put}_compat_timspec 4/8 x86_64 Stephen Rothwell
2003-01-08 12:01 ` [PATCH][COMPAT] {get,put}_compat_timspec 5/8 ia64 Stephen Rothwell
2003-01-08 12:04 ` [PATCH][COMPAT] {get,put}_compat_timspec 6/8 s390x Stephen Rothwell
2003-01-08 12:10 ` [PATCH][COMPAT] {get,put}_compat_timspec 7/8 mips64 Stephen Rothwell
2003-01-08 12:12 ` [PATCH][COMPAT] {get,put}_compat_timspec 8/8 parisc Stephen Rothwell

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=20030108223744.0c4856b7.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ak@muc.de \
    --cc=anton@samba.org \
    --cc=davem@redhat.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=ralf@gnu.org \
    --cc=schwidefsky@de.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.