diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2016-08-21 19:16:26 -0400 |
|---|---|---|
| committer | Sasha Levin <alexander.levin@verizon.com> | 2016-10-02 21:14:13 -0400 |
| commit | 5a1bd17484e4042635c515595305e05e9c67aff5 (patch) | |
| tree | d088a0c95f282f73229f79ce8a37737316814839 | |
| parent | f39be7f631c7ce7b721b0568510b73266ce4b3e9 (diff) | |
| download | linux-5a1bd17484e4042635c515595305e05e9c67aff5.tar.gz linux-5a1bd17484e4042635c515595305e05e9c67aff5.tar.bz2 linux-5a1bd17484e4042635c515595305e05e9c67aff5.zip | |
ppc32: fix copy_from_user()
[ Upstream commit 224264657b8b228f949b42346e09ed8c90136a8e ]
should clear on access_ok() failures. Also remove the useless
range truncation logics.
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
| -rw-r--r-- | arch/powerpc/include/asm/uaccess.h | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index a0c071d24e0e..6fbea25d8c78 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -323,30 +323,17 @@ extern unsigned long __copy_tofrom_user(void __user *to, static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) { - unsigned long over; - - if (access_ok(VERIFY_READ, from, n)) + if (likely(access_ok(VERIFY_READ, from, n))) return __copy_tofrom_user((__force void __user *)to, from, n); - if ((unsigned long)from < TASK_SIZE) { - over = (unsigned long)from + n - TASK_SIZE; - return __copy_tofrom_user((__force void __user *)to, from, - n - over) + over; - } + memset(to, 0, n); return n; } static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) { - unsigned long over; - if (access_ok(VERIFY_WRITE, to, n)) return __copy_tofrom_user(to, (__force void __user *)from, n); - if ((unsigned long)to < TASK_SIZE) { - over = (unsigned long)to + n - TASK_SIZE; - return __copy_tofrom_user(to, (__force void __user *)from, - n - over) + over; - } return n; } @@ -437,10 +424,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long size) might_fault(); if (likely(access_ok(VERIFY_WRITE, addr, size))) return __clear_user(addr, size); - if ((unsigned long)addr < TASK_SIZE) { - unsigned long over = (unsigned long)addr + size - TASK_SIZE; - return __clear_user(addr, size - over) + over; - } return size; } |
