public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault
@ 2016-08-19 19:10 Vineet Gupta
  2016-08-19 21:24 ` Al Viro
  0 siblings, 1 reply; 21+ messages in thread
From: Vineet Gupta @ 2016-08-19 19:10 UTC (permalink / raw)
  To: Al Viro
  Cc: Alexey Brodkin, Vineet Gupta, Linus Torvalds, linux-snps-arc,
	linux-kernel, stable

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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-08-23  0:17 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-19 19:10 [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault Vineet Gupta
2016-08-19 21:24 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox