Commit a683a93b authored by Vineet Gupta's avatar Vineet Gupta Committed by Greg Kroah-Hartman

ARC: Fix 32-bit wrap around in access_ok()

commit 0752adfd 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: default avatarAnton Kolesov <Anton.Kolesov@synopsys.com>
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5cd12e77
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* Because it essentially checks if buffer end is within limit and @len is * Because it essentially checks if buffer end is within limit and @len is
* non-ngeative, which implies that buffer start will be within limit too. * non-ngeative, which implies that buffer start will be within limit too.
* *
* The reason for rewriting being, for majorit yof cases, @len is generally * The reason for rewriting being, for majority of cases, @len is generally
* compile time constant, causing first sub-expression to be compile time * compile time constant, causing first sub-expression to be compile time
* subsumed. * subsumed.
* *
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
* *
*/ */
#define __user_ok(addr, sz) (((sz) <= TASK_SIZE) && \ #define __user_ok(addr, sz) (((sz) <= TASK_SIZE) && \
(((addr)+(sz)) <= get_fs())) ((addr) <= (get_fs() - (sz))))
#define __access_ok(addr, sz) (unlikely(__kernel_ok) || \ #define __access_ok(addr, sz) (unlikely(__kernel_ok) || \
likely(__user_ok((addr), (sz)))) likely(__user_ok((addr), (sz))))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment