diff options
authorYann Droneaud <>2015-06-22 21:38:43 +0200
committerIngo Molnar <>2015-07-06 14:09:27 +0200
commitebf2d2689de551d90965090bb991fc640a0c0d41 (patch)
parent57ffc5ca679f499f4704fd9b6a372916f59930ee (diff)
perf/x86: Fix copy_from_user_nmi() return if range is not ok
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 <> Signed-off-by: Peter Zijlstra (Intel) <> Cc: Linus Torvalds <> Cc: Peter Zijlstra <> Cc: Thomas Gleixner <> Link: Signed-off-by: Ingo Molnar <>
1 files changed, 1 insertions, 1 deletions
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