From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:39880 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932898AbcI2JHF (ORCPT ); Thu, 29 Sep 2016 05:07:05 -0400 From: Jiri Slaby To: stable@vger.kernel.org Cc: Al Viro , Jiri Slaby Subject: [patch added to 3.12-stable] microblaze: fix copy_from_user() Date: Thu, 29 Sep 2016 11:06:28 +0200 Message-Id: <20160929090654.27405-17-jslaby@suse.cz> In-Reply-To: <20160929090654.27405-1-jslaby@suse.cz> References: <20160929090654.27405-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Al Viro This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit d0cf385160c12abd109746cad1f13e3b3e8b50b8 upstream. Signed-off-by: Al Viro Signed-off-by: Jiri Slaby --- arch/microblaze/include/asm/uaccess.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 19f8f415c034..1858887105ba 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h @@ -371,10 +371,13 @@ extern long __user_bad(void); static inline long copy_from_user(void *to, const void __user *from, unsigned long n) { + unsigned long res = n; might_fault(); - if (access_ok(VERIFY_READ, from, n)) - return __copy_from_user(to, from, n); - return n; + if (likely(access_ok(VERIFY_READ, from, n))) + res = __copy_from_user(to, from, n); + if (unlikely(res)) + memset(to + (n - res), 0, res); + return res; } #define __copy_to_user(to, from, n) \ -- 2.10.0