Skip to content

Commit

Permalink
perf/x86: Fix copy_from_user_nmi() return if range is not ok
Browse files Browse the repository at this point in the history
Commit 0a19684 ("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 0a19684, 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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1435001923-30986-1-git-send-email-ydroneaud@opteya.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Yann Droneaud authored and Ingo Molnar committed Jul 6, 2015
1 parent 57ffc5c commit ebf2d26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/lib/usercopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebf2d26

Please sign in to comment.