Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754061AbbGFPfQ (ORCPT ); Mon, 6 Jul 2015 11:35:16 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48992 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251AbbGFPfM (ORCPT ); Mon, 6 Jul 2015 11:35:12 -0400 Date: Mon, 6 Jul 2015 08:34:33 -0700 From: tip-bot for Yann Droneaud Message-ID: Cc: peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, ydroneaud@opteya.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org Reply-To: peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, ydroneaud@opteya.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org In-Reply-To: <1435001923-30986-1-git-send-email-ydroneaud@opteya.com> References: <1435001923-30986-1-git-send-email-ydroneaud@opteya.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86: Fix copy_from_user_nmi() return if range is not ok Git-Commit-ID: ebf2d2689de551d90965090bb991fc640a0c0d41 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2004 Lines: 51 Commit-ID: ebf2d2689de551d90965090bb991fc640a0c0d41 Gitweb: http://git.kernel.org/tip/ebf2d2689de551d90965090bb991fc640a0c0d41 Author: Yann Droneaud AuthorDate: Mon, 22 Jun 2015 21:38:43 +0200 Committer: Ingo Molnar 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1435001923-30986-1-git-send-email-ydroneaud@opteya.com Signed-off-by: Ingo Molnar --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/