public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: fix copy_from_user_nmi() return if range is not ok
@ 2015-06-22 19:38 Yann Droneaud
  2015-07-06 15:34 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Yann Droneaud
  0 siblings, 1 reply; 4+ messages in thread
From: Yann Droneaud @ 2015-06-22 19:38 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: x86, linux-kernel, Yann Droneaud

Commit 0a196848ca36 ("perf: Fix arch_perf_out_copy_user default"),
changes copy_from_user_nmi() to return the number of
remaining bytes so that it behave like copy_from_user().

Unfortunately, when the range is outside of the process,
memory the return value  is still the number of byte
copied, eg. 0, instead of the remaining bytes.

As all users of copy_from_user_nmi() were modified as
part of commit 0a196848ca36, the function should be
fixed to return the total number of bytes if range is
not correct.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 arch/x86/lib/usercopy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index ddf9ecb53cc3..e342586db6e4 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -20,7 +20,7 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 	unsigned long ret;
 
 	if (__range_not_ok(from, n, TASK_SIZE))
-		return 0;
+		return n;
 
 	/*
 	 * Even though this function is typically called from NMI/IRQ context
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2015-09-28 13:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-22 19:38 [PATCH] x86: fix copy_from_user_nmi() return if range is not ok Yann Droneaud
2015-07-06 15:34 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Yann Droneaud
2015-09-08  8:20   ` [-stable] " Yann Droneaud
2015-09-28 13:18     ` Luis Henriques

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