From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
Vineet Gupta <Vineet.Gupta1@synopsys.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
<linux-snps-arc@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault
Date: Fri, 19 Aug 2016 12:10:02 -0700 [thread overview]
Message-ID: <1471633802-2936-1-git-send-email-vgupta@synopsys.com> (raw)
Al reported potential issue with ARC get_user() as it wasn't clearing
out destination pointer in case of fault due to bad address etc.
Verified using following
| {
| u32 bogus1 = 0xdeadbeef;
| u64 bogus2 = 0xdead;
| int rc1, rc2;
|
| pr_info("Orig values %x %llx\n", bogus1, bogus2);
| rc1 = get_user(bogus1, (u32 __user *)0x40000000);
| rc2 = get_user(bogus2, (u64 __user *)0x50000000);
| pr_info("access %d %d, new values %x %llx\n",
| rc1, rc2, bogus1, bogus2);
| }
| [ARCLinux]# insmod /mnt/kernel-module/qtn.ko
| Orig values deadbeef dead
| access -14 -14, new values 0 0
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
arch/arc/include/asm/uaccess.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index a78d5670884f..41faf17cd28d 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -83,7 +83,10 @@
"2: ;nop\n" \
" .section .fixup, \"ax\"\n" \
" .align 4\n" \
- "3: mov %0, %3\n" \
+ "3: # return -EFAULT\n" \
+ " mov %0, %3\n" \
+ " # zero out dst ptr\n" \
+ " mov %1, 0\n" \
" j 2b\n" \
" .previous\n" \
" .section __ex_table, \"a\"\n" \
@@ -101,7 +104,11 @@
"2: ;nop\n" \
" .section .fixup, \"ax\"\n" \
" .align 4\n" \
- "3: mov %0, %3\n" \
+ "3: # return -EFAULT\n" \
+ " mov %0, %3\n" \
+ " # zero out dst ptr\n" \
+ " mov %1, 0\n" \
+ " mov %R1, 0\n" \
" j 2b\n" \
" .previous\n" \
" .section __ex_table, \"a\"\n" \
--
2.7.4
next reply other threads:[~2016-08-19 19:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 19:10 Vineet Gupta [this message]
2016-08-19 21:24 ` [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault Al Viro
2016-08-19 22:00 ` Linus Torvalds
2016-08-19 22:11 ` Linus Torvalds
2016-08-20 23:32 ` Linus Torvalds
2016-08-21 0:11 ` Al Viro
2016-08-21 0:45 ` Linus Torvalds
2016-08-21 1:00 ` Linus Torvalds
2016-08-21 1:09 ` H. Peter Anvin
2016-08-21 1:40 ` Al Viro
2016-08-21 4:54 ` Jakub Jelinek
2016-08-21 6:42 ` Al Viro
2016-08-21 17:52 ` Linus Torvalds
2016-08-22 22:23 ` Linus Torvalds
2016-08-22 23:12 ` H. Peter Anvin
2016-08-22 23:48 ` Linus Torvalds
2016-08-22 23:51 ` H. Peter Anvin
2016-08-22 23:57 ` David Miller
2016-08-23 0:09 ` H. Peter Anvin
2016-08-23 0:17 ` Al Viro
2016-08-22 23:19 ` H. Peter Anvin
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=1471633802-2936-1-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=Alexey.Brodkin@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/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