Skip to content

Commit

Permalink
microblaze: Fix uaccess_ok macro
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michal Simek committed May 9, 2013
1 parent 6dc92c9 commit f663b60
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions arch/microblaze/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,25 @@ static inline int ___range_ok(unsigned long addr, unsigned long size)

#else

/*
* Address is valid if:
* - "addr", "addr + size" and "size" are all below the limit
*/
#define access_ok(type, addr, size) \
(get_fs().seg >= (((unsigned long)(addr)) | \
(size) | ((unsigned long)(addr) + (size))))

/* || printk("access_ok failed for %s at 0x%08lx (size %d), seg 0x%08x\n",
type?"WRITE":"READ",addr,size,get_fs().seg)) */

static inline int access_ok(int type, const void __user *addr,
unsigned long size)
{
if (!size)
goto ok;

if ((get_fs().seg < ((unsigned long)addr)) ||
(get_fs().seg < ((unsigned long)addr + size - 1))) {
pr_debug("ACCESS fail: %s at 0x%08x (size 0x%x), seg 0x%08x\n",
type ? "WRITE" : "READ ", (u32)addr, (u32)size,
(u32)get_fs().seg);
return 0;
}
ok:
pr_debug("ACCESS OK: %s at 0x%08x (size 0x%x), seg 0x%08x\n",
type ? "WRITE" : "READ ", (u32)addr, (u32)size,
(u32)get_fs().seg);
return 1;
}
#endif

#ifdef CONFIG_MMU
Expand Down

0 comments on commit f663b60

Please sign in to comment.