Skip to content

Commit 7b081ad

Browse files
vineetgarcgregkh
authored andcommitted
ARC: Fix 32-bit wrap around in access_ok()
commit 0752adf upstream. Anton reported | LTP tests syscalls/process_vm_readv01 and process_vm_writev01 fail | similarly in one testcase test_iov_invalid -> lvec->iov_base. | Testcase expects errno EFAULT and return code -1, | but it gets return code 1 and ERRNO is 0 what means success. Essentially test case was passing a pointer of -1 which access_ok() was not catching. It was doing [@addr + @sz <= TASK_SIZE] which would pass for @addr == -1 Fixed that by rewriting as [@addr <= TASK_SIZE - @sz] Reported-by: Anton Kolesov <[email protected]> Signed-off-by: Vineet Gupta <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 49cac7d commit 7b081ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arc/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* Because it essentially checks if buffer end is within limit and @len is
4444
* non-ngeative, which implies that buffer start will be within limit too.
4545
*
46-
* The reason for rewriting being, for majorit yof cases, @len is generally
46+
* The reason for rewriting being, for majority of cases, @len is generally
4747
* compile time constant, causing first sub-expression to be compile time
4848
* subsumed.
4949
*
@@ -53,7 +53,7 @@
5353
*
5454
*/
5555
#define __user_ok(addr, sz) (((sz) <= TASK_SIZE) && \
56-
(((addr)+(sz)) <= get_fs()))
56+
((addr) <= (get_fs() - (sz))))
5757
#define __access_ok(addr, sz) (unlikely(__kernel_ok) || \
5858
likely(__user_ok((addr), (sz))))
5959

0 commit comments

Comments
 (0)