summaryrefslogtreecommitdiffstats
path: root/arch/um/include/um_uaccess.h
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso2005-11-14 01:07:13 +0100
committerLinus Torvalds2005-11-14 03:14:15 +0100
commit7a590611c0f1e1302c58fdfdc958f2d6bdddd78a (patch)
treead57f5bda5245af1d03ba10e15308487b1aae9c7 /arch/um/include/um_uaccess.h
parent[PATCH] uml console channels: fix the API of console_write (diff)
downloadkernel-qcow2-linux-7a590611c0f1e1302c58fdfdc958f2d6bdddd78a.tar.gz
kernel-qcow2-linux-7a590611c0f1e1302c58fdfdc958f2d6bdddd78a.tar.xz
kernel-qcow2-linux-7a590611c0f1e1302c58fdfdc958f2d6bdddd78a.zip
[PATCH] uml: fix access_ok
The access_ok_tt() macro is bogus, in that a read access is unconditionally considered valid. I couldn't find in SCM logs the introduction of this check, but I went back to 2.4.20-1um and the definition was the same. Possibly this was done to avoid problems with missing set_fs() calls, but there can't be any I think because they would fail with SKAS mode. TT-specific code is still to check. Also, this patch joins common code together, and makes the "address range wrapping" check happen for all cases, rather than for only some. This may, possibly, be reoptimized at some time, but the current code doesn't seem clever, just confused. * Important: I've also had to change references to access_ok_{tt,skas} back to access_ok - the kernel wasn't that happy otherwise. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Acked-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/include/um_uaccess.h')
-rw-r--r--arch/um/include/um_uaccess.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/um/include/um_uaccess.h b/arch/um/include/um_uaccess.h
index 84c0868cd561..f8760a3f43b0 100644
--- a/arch/um/include/um_uaccess.h
+++ b/arch/um/include/um_uaccess.h
@@ -17,8 +17,25 @@
#include "uaccess-skas.h"
#endif
+#define __under_task_size(addr, size) \
+ (((unsigned long) (addr) < TASK_SIZE) && \
+ (((unsigned long) (addr) + (size)) < TASK_SIZE))
+
+#define __access_ok_vsyscall(type, addr, size) \
+ ((type == VERIFY_READ) && \
+ ((unsigned long) (addr) >= FIXADDR_USER_START) && \
+ ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
+ ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
+
+#define __addr_range_nowrap(addr, size) \
+ ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
+
#define access_ok(type, addr, size) \
- CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)
+ (__addr_range_nowrap(addr, size) && \
+ (__under_task_size(addr, size) || \
+ __access_ok_vsyscall(type, addr, size) || \
+ segment_eq(get_fs(), KERNEL_DS) || \
+ CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)))
static inline int copy_from_user(void *to, const void __user *from, int n)
{