All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][COMPAT] {get,put}_compat_timspec 1/8 generic
@ 2003-01-08 11:37 Stephen Rothwell
  2003-01-08 11:41 ` [PATCH][COMPAT] {get,put}_compat_timspec 2/8 ppc64 Stephen Rothwell
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Stephen Rothwell @ 2003-01-08 11:37 UTC (permalink / raw)
  To: Linus; +Cc: LKML, anton, David S. Miller, ak, davidm, schwidefsky, ralf,
	matthew

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;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-01-08 12:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-08 11:37 [PATCH][COMPAT] {get,put}_compat_timspec 1/8 generic Stephen Rothwell
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

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.