Skip to contentSkip to conversation

more correct get_compat_timespec interface

PATCH Jon Foster 2 participants 2 messages Dec 3, 2003

lore
Share & tools
lore

Jon Foster

author
#0 lore raw

Hi,

Quoted 5 lines
(quoted diff) +1 -1
-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) ||

Shouldn't the "const" be on the other argument?

Kind regards,

Jon Foster

#1 lore raw
Quoted 4 lines · Jon Foster
(quoted diff) +1 -1
-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

include/linux/compat.h +2 -2
diff -ura 2.6.0-test11-base/include/linux/compat.h 2.6.0-test11-new/include/linux/compat.h
@@ -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;
kernel/compat.c +2 -2
diff -ura 2.6.0-test11-base/kernel/compat.c 2.6.0-test11-new/kernel/compat.c
@@ -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) ||