* put_user/get_user warnings for x86
@ 2002-06-15 20:03 Rusty Russell
0 siblings, 0 replies; only message in thread
From: Rusty Russell @ 2002-06-15 20:03 UTC (permalink / raw)
To: linux-kernel; +Cc: torvalds
It's not *neccessarily wrong* to use put_user(int, long *), but it's
probably worth warning for:
Name: put_user/get_user extra checks (x86 only)
Author: Rusty Russell
Status: Trivial
D: This makes put_user and get_user warn if the type of the userspace ptr
D: and the kernel variable are incompatible, eg:
D: int x;
D: char *uptr;
D: ...
D: put_user(x,uptr); <= Warn here
D: get_user(x,uptr); <= Warn here
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.21/include/asm-i386/uaccess.h working-2.5.21-putusercheck/include/asm-i386/uaccess.h
--- linux-2.5.21/include/asm-i386/uaccess.h Wed Feb 20 17:56:40 2002
+++ working-2.5.21-putusercheck/include/asm-i386/uaccess.h Sun Jun 16 05:55:27 2002
@@ -133,16 +133,18 @@
extern void __put_user_bad(void);
#define put_user(x,ptr) \
- __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+ __put_user_check((x),(ptr),sizeof(*(ptr)))
#define __get_user(x,ptr) \
__get_user_nocheck((x),(ptr),sizeof(*(ptr)))
#define __put_user(x,ptr) \
- __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+ __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
#define __put_user_nocheck(x,ptr,size) \
({ \
long __pu_err; \
+ /* Elicit warning */ \
+ __typeof__(x) *__pu_check __attribute__((unused)) = ptr; \
__put_user_size((x),(ptr),(size),__pu_err); \
__pu_err; \
})
@@ -151,7 +153,8 @@
#define __put_user_check(x,ptr,size) \
({ \
long __pu_err = -EFAULT; \
- __typeof__(*(ptr)) *__pu_addr = (ptr); \
+ /* Elicit warning */ \
+ __typeof__(x) *__pu_addr = (ptr); \
if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
__put_user_size((x),__pu_addr,(size),__pu_err); \
__pu_err; \
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-06-15 20:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-15 20:03 put_user/get_user warnings for x86 Rusty Russell
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®