linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH, 2.6.0-test11] more correct get_compat_timespec interface
@ 2003-12-02 22:16 Joe Korty
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Korty @ 2003-12-02 22:16 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hi Andrew, 
 The API for get_compat_timespec / put_compat_timespec is incorrect, it
forces a caller with const args to (incorrectly) cast.  The posix message
queue patch is one such caller.

Joe



diff -ura 2.6.0-test11-base/include/linux/compat.h 2.6.0-test11-new/include/linux/compat.h
--- 2.6.0-test11-base/include/linux/compat.h	2003-11-26 15:43:56.000000000 -0500
+++ 2.6.0-test11-new/include/linux/compat.h	2003-12-02 15:48:14.000000000 -0500
@@ -44,8 +44,8 @@
 } compat_sigset_t;
 
 extern int cp_compat_stat(struct kstat *, struct compat_stat *);
-extern int get_compat_timespec(struct timespec *, struct compat_timespec *);
-extern int put_compat_timespec(struct timespec *, struct compat_timespec *);
+extern int get_compat_timespec(struct timespec *, const struct compat_timespec *);
+extern int put_compat_timespec(struct timespec *, const struct compat_timespec *);
 
 struct compat_iovec {
 	compat_uptr_t	iov_base;
diff -ura 2.6.0-test11-base/kernel/compat.c 2.6.0-test11-new/kernel/compat.c
--- 2.6.0-test11-base/kernel/compat.c	2003-11-26 15:44:11.000000000 -0500
+++ 2.6.0-test11-new/kernel/compat.c	2003-12-02 15:48:14.000000000 -0500
@@ -22,14 +22,14 @@
 
 #include <asm/uaccess.h>
 
-int get_compat_timespec(struct timespec *ts, struct compat_timespec *cts)
+int get_compat_timespec(struct timespec *ts, const 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)
+int put_compat_timespec(struct timespec *ts, const struct compat_timespec *cts)
 {
 	return (verify_area(VERIFY_WRITE, cts, sizeof(*cts)) ||
 			__put_user(ts->tv_sec, &cts->tv_sec) ||

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

* Re: [PATCH, 2.6.0-test11] more correct get_compat_timespec interface
  2003-12-03 18:51 Jon Foster
@ 2003-12-03 21:31 ` Joe Korty
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Korty @ 2003-12-03 21:31 UTC (permalink / raw)
  To: Jon Foster; +Cc: linux-kernel

On Wed, Dec 03, 2003 at 06:51:19PM +0000, Jon Foster wrote:
>-int put_compat_timespec(struct timespec *ts, struct compat_timespec *cts)
>+int put_compat_timespec(struct timespec *ts, const struct compat_timespec *cts)
> 
> Shouldn't the "const" be on the other argument?

Indeed it should.  Here is the new and improved version, also with '__user' added
at the correct spots.

Regards,
Joe


diff -ura 2.6.0-test11-base/include/linux/compat.h 2.6.0-test11-new/include/linux/compat.h
--- 2.6.0-test11-base/include/linux/compat.h	2003-11-26 15:43:56.000000000 -0500
+++ 2.6.0-test11-new/include/linux/compat.h	2003-12-03 16:04:17.000000000 -0500
@@ -44,8 +44,8 @@
 } compat_sigset_t;
 
 extern int cp_compat_stat(struct kstat *, struct compat_stat *);
-extern int get_compat_timespec(struct timespec *, struct compat_timespec *);
-extern int put_compat_timespec(struct timespec *, struct compat_timespec *);
+extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
+extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
 
 struct compat_iovec {
 	compat_uptr_t	iov_base;
diff -ura 2.6.0-test11-base/kernel/compat.c 2.6.0-test11-new/kernel/compat.c
--- 2.6.0-test11-base/kernel/compat.c	2003-11-26 15:44:11.000000000 -0500
+++ 2.6.0-test11-new/kernel/compat.c	2003-12-03 16:04:17.000000000 -0500
@@ -22,14 +22,14 @@
 
 #include <asm/uaccess.h>
 
-int get_compat_timespec(struct timespec *ts, struct compat_timespec *cts)
+int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *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)
+int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
 {
 	return (verify_area(VERIFY_WRITE, cts, sizeof(*cts)) ||
 			__put_user(ts->tv_sec, &cts->tv_sec) ||

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-02 22:16 [PATCH, 2.6.0-test11] more correct get_compat_timespec interface Joe Korty
2003-12-03 18:51 Jon Foster
2003-12-03 21:31 ` [PATCH, " Joe Korty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).