]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.11.6/arc-fix-32-bit-wrap-around-in-access_ok.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.11.6 / arc-fix-32-bit-wrap-around-in-access_ok.patch
CommitLineData
f70c4f3b
GKH
1From 0752adfda15f0eca9859a76da3db1800e129ad43 Mon Sep 17 00:00:00 2001
2From: Vineet Gupta <vgupta@synopsys.com>
3Date: Thu, 26 Sep 2013 18:50:40 +0530
4Subject: ARC: Fix 32-bit wrap around in access_ok()
5
6From: Vineet Gupta <vgupta@synopsys.com>
7
8commit 0752adfda15f0eca9859a76da3db1800e129ad43 upstream.
9
10Anton 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
17Essentially test case was passing a pointer of -1 which access_ok()
18was not catching. It was doing [@addr + @sz <= TASK_SIZE] which would
19pass for @addr == -1
20
21Fixed that by rewriting as [@addr <= TASK_SIZE - @sz]
22
23Reported-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
24Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
25Signed-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