aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-03-28 11:42:44 -0400
committerMichal Simek <michal.simek@xilinx.com>2013-05-09 03:04:32 -0400
commitf663b60f5215b44d147ee0c07d17ffd7e9f3f881 (patch)
treedef7dc04d57d626adbf66a8eedef49a09bb8c9a1
parent6dc92c9c3f209cb07fbf282b470ed76787bbc5f8 (diff)
microblaze: Fix uaccess_ok macro
Fix access_ok macro no to permit case where user will try to access the last address space which is equal to segment address. Example: segment addr = 0xbfff ffff address = 0xbfff fff0 size = 0x10 Current wrong implementation 0xbfff ffff >= (0xbfff fff0 | 0x10 | (0xbfff fff0 + 0x10)) 0xbfff ffff >= (0xbfff fff0 | 0xc000 0000) 0xbfff ffff >= 0xf000 0000 return 0 which is access failed even the combination is valid. because get_fs().seq returns the last valid address. This patch fix this problem. Size equals to zero is valid access. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
-rw-r--r--arch/microblaze/include/asm/uaccess.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index a1ab5f0009ef..efe59d881789 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -90,17 +90,25 @@ static inline int ___range_ok(unsigned long addr, unsigned long size)
90 90
91#else 91#else
92 92
93/* 93static inline int access_ok(int type, const void __user *addr,
94 * Address is valid if: 94 unsigned long size)
95 * - "addr", "addr + size" and "size" are all below the limit 95{
96 */ 96 if (!size)
97#define access_ok(type, addr, size) \ 97 goto ok;
98 (get_fs().seg >= (((unsigned long)(addr)) | \ 98
99 (size) | ((unsigned long)(addr) + (size)))) 99 if ((get_fs().seg < ((unsigned long)addr)) ||
100 100 (get_fs().seg < ((unsigned long)addr + size - 1))) {
101/* || printk("access_ok failed for %s at 0x%08lx (size %d), seg 0x%08x\n", 101 pr_debug("ACCESS fail: %s at 0x%08x (size 0x%x), seg 0x%08x\n",
102 type?"WRITE":"READ",addr,size,get_fs().seg)) */ 102 type ? "WRITE" : "READ ", (u32)addr, (u32)size,
103 103 (u32)get_fs().seg);
104 return 0;
105 }
106ok:
107 pr_debug("ACCESS OK: %s at 0x%08x (size 0x%x), seg 0x%08x\n",
108 type ? "WRITE" : "READ ", (u32)addr, (u32)size,
109 (u32)get_fs().seg);
110 return 1;
111}
104#endif 112#endif
105 113
106#ifdef CONFIG_MMU 114#ifdef CONFIG_MMU