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

* [tip:perf/urgent] perf/x86: Fix copy_from_user_nmi() return if range is not ok
  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-bot for Yann Droneaud
  2015-09-08  8:20   ` [-stable] " Yann Droneaud
  0 siblings, 1 reply; 4+ messages in thread
From: tip-bot for Yann Droneaud @ 2015-07-06 15:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, hpa, mingo, tglx, ydroneaud, linux-kernel, torvalds

Commit-ID:  ebf2d2689de551d90965090bb991fc640a0c0d41
Gitweb:     http://git.kernel.org/tip/ebf2d2689de551d90965090bb991fc640a0c0d41
Author:     Yann Droneaud <ydroneaud@opteya.com>
AuthorDate: Mon, 22 Jun 2015 21:38:43 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 6 Jul 2015 14:09:27 +0200

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 <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>
---
 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 ddf9ecb..e342586 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

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

* [-stable] perf/x86: Fix copy_from_user_nmi() return if range is not ok
  2015-07-06 15:34 ` [tip:perf/urgent] perf/x86: Fix " tip-bot for Yann Droneaud
@ 2015-09-08  8:20   ` Yann Droneaud
  2015-09-28 13:18     ` Luis Henriques
  0 siblings, 1 reply; 4+ messages in thread
From: Yann Droneaud @ 2015-09-08  8:20 UTC (permalink / raw)
  To: stable; +Cc: peterz, hpa, mingo, tglx, torvalds, linux-kernel, x86, ydroneaud

Hi,

I believe commit ebf2d2689de551d90965090bb991fc640a0c0d41
("perf/x86: Fix copy_from_user_nmi() return if range is not ok")
should be applied to stable kernels starting from v3.13.y up to v4.1.y.

Regards.

-- 
Yann Droneaud
OPTEYA


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

* Re: [-stable] perf/x86: Fix copy_from_user_nmi() return if range is not ok
  2015-09-08  8:20   ` [-stable] " Yann Droneaud
@ 2015-09-28 13:18     ` Luis Henriques
  0 siblings, 0 replies; 4+ messages in thread
From: Luis Henriques @ 2015-09-28 13:18 UTC (permalink / raw)
  To: Yann Droneaud
  Cc: stable, peterz, hpa, mingo, tglx, torvalds, linux-kernel, x86

On Tue, Sep 08, 2015 at 10:20:32AM +0200, Yann Droneaud wrote:
> Hi,
> 
> I believe commit ebf2d2689de551d90965090bb991fc640a0c0d41
> ("perf/x86: Fix copy_from_user_nmi() return if range is not ok")
> should be applied to stable kernels starting from v3.13.y up to v4.1.y.
>

Thank you, I'm queuing it for the 3.16 kernel.

Cheers,
--
Luís


> Regards.
> 
> -- 
> Yann Droneaud
> OPTEYA
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[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