linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Cc: arc-linux-dev@synopsys.com, u.kleine-koenig@pengutronix.de,
	Noam Camus <noamc@ezchip.com>,
	Gilad Ben-Yossef <gilad@benyossef.com>,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>
Subject: [PATCH 2/4] ARC: Fix 32-bit wrap around in access_ok()
Date: Fri, 27 Sep 2013 16:27:35 +0530	[thread overview]
Message-ID: <1380279457-14299-3-git-send-email-vgupta@synopsys.com> (raw)
In-Reply-To: <1380279457-14299-1-git-send-email-vgupta@synopsys.com>

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 <Anton.Kolesov@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index 3242082..30c9baf 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -43,7 +43,7 @@
  * 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.
  *
- * 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
  * subsumed.
  *
@@ -53,7 +53,7 @@
  *
  */
 #define __user_ok(addr, sz)	(((sz) <= TASK_SIZE) && \
-				 (((addr)+(sz)) <= get_fs()))
+				 ((addr) <= (get_fs() - (sz))))
 #define __access_ok(addr, sz)	(unlikely(__kernel_ok) || \
 				 likely(__user_ok((addr), (sz))))
 
-- 
1.8.1.2

  parent reply	other threads:[~2013-09-27 10:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 10:57 [PATCH 0/4] ARC fixes for 3.12-rc3 Vineet Gupta
2013-09-27 10:57 ` Vineet Gupta
2013-09-27 10:57 ` [PATCH 1/4] ARC: Handle zero-overhead-loop in unaligned access handler Vineet Gupta
2013-09-27 10:57 ` Vineet Gupta [this message]
2013-09-27 10:57   ` [PATCH 2/4] ARC: Fix 32-bit wrap around in access_ok() Vineet Gupta
2013-09-27 10:57 ` [PATCH 3/4] ARC: Workaround spinlock livelock in SMP SystemC simulation Vineet Gupta
2013-09-27 10:57   ` Vineet Gupta
2013-09-27 10:57 ` [PATCH 4/4] ARC: Use clockevents_config_and_register over clockevents_register_device Vineet Gupta
2013-09-27 10:57   ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380279457-14299-3-git-send-email-vgupta@synopsys.com \
    --to=vineet.gupta1@synopsys.com \
    --cc=arc-linux-dev@synopsys.com \
    --cc=gilad@benyossef.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noamc@ezchip.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).