]>
Commit | Line | Data |
---|---|---|
f70c4f3b GKH |
1 | From 0752adfda15f0eca9859a76da3db1800e129ad43 Mon Sep 17 00:00:00 2001 |
2 | From: Vineet Gupta <vgupta@synopsys.com> | |
3 | Date: Thu, 26 Sep 2013 18:50:40 +0530 | |
4 | Subject: ARC: Fix 32-bit wrap around in access_ok() | |
5 | ||
6 | From: Vineet Gupta <vgupta@synopsys.com> | |
7 | ||
8 | commit 0752adfda15f0eca9859a76da3db1800e129ad43 upstream. | |
9 | ||
10 | Anton reported | |
11 | ||
12 | | LTP tests syscalls/process_vm_readv01 and process_vm_writev01 fail | |
13 | | similarly in one testcase test_iov_invalid -> lvec->iov_base. | |
14 | | Testcase expects errno EFAULT and return code -1, | |
15 | | but it gets return code 1 and ERRNO is 0 what means success. | |
16 | ||
17 | Essentially test case was passing a pointer of -1 which access_ok() | |
18 | was not catching. It was doing [@addr + @sz <= TASK_SIZE] which would | |
19 | pass for @addr == -1 | |
20 | ||
21 | Fixed that by rewriting as [@addr <= TASK_SIZE - @sz] | |
22 | ||
23 | Reported-by: Anton Kolesov <Anton.Kolesov@synopsys.com> | |
24 | Signed-off-by: Vineet Gupta <vgupta@synopsys.com> | |
25 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
26 | ||
27 | --- | |
28 | arch/arc/include/asm/uaccess.h | 4 ++-- | |
29 | 1 file changed, 2 insertions(+), 2 deletions(-) | |
30 | ||
31 | --- a/arch/arc/include/asm/uaccess.h | |
32 | +++ b/arch/arc/include/asm/uaccess.h | |
33 | @@ -43,7 +43,7 @@ | |
34 | * Because it essentially checks if buffer end is within limit and @len is | |
35 | * non-ngeative, which implies that buffer start will be within limit too. | |
36 | * | |
37 | - * The reason for rewriting being, for majorit yof cases, @len is generally | |
38 | + * The reason for rewriting being, for majority of cases, @len is generally | |
39 | * compile time constant, causing first sub-expression to be compile time | |
40 | * subsumed. | |
41 | * | |
42 | @@ -53,7 +53,7 @@ | |
43 | * | |
44 | */ | |
45 | #define __user_ok(addr, sz) (((sz) <= TASK_SIZE) && \ | |
46 | - (((addr)+(sz)) <= get_fs())) | |
47 | + ((addr) <= (get_fs() - (sz)))) | |
48 | #define __access_ok(addr, sz) (unlikely(__kernel_ok) || \ | |
49 | likely(__user_ok((addr), (sz)))) | |
50 |