Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc: copy_from_user() should not return -EFAULT

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Callers of copy_from_user() expect it to return the number of bytes
it could not copy. In no case it is supposed to return -EFAULT.

In case of a detected buffer overflow just return the requested
length. In addition one could think of a memset that would clear
the size of the target object.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Heiko Carstens and committed by
David S. Miller
6df1c176 e04ed38d

+2 -2
+1 -1
arch/sparc/include/asm/uaccess_32.h
··· 274 274 275 275 if (unlikely(sz != -1 && sz < n)) { 276 276 copy_from_user_overflow(); 277 - return -EFAULT; 277 + return n; 278 278 } 279 279 280 280 if (n && __access_ok((unsigned long) from, n))
+1 -1
arch/sparc/include/asm/uaccess_64.h
··· 221 221 static inline unsigned long __must_check 222 222 copy_from_user(void *to, const void __user *from, unsigned long size) 223 223 { 224 - unsigned long ret = (unsigned long) -EFAULT; 225 224 int sz = __compiletime_object_size(to); 225 + unsigned long ret = size; 226 226 227 227 if (likely(sz == -1 || sz >= size)) { 228 228 ret = ___copy_from_user(to, from, size);