Skip to content

Commit

Permalink
sparc: copy_from_user() should not return -EFAULT
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Carstens authored and David S. Miller committed Jan 6, 2010
1 parent e04ed38 commit 6df1c17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/uaccess_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static inline unsigned long copy_from_user(void *to, const void __user *from, un

if (unlikely(sz != -1 && sz < n)) {
copy_from_user_overflow();
return -EFAULT;
return n;
}

if (n && __access_ok((unsigned long) from, n))
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
static inline unsigned long __must_check
copy_from_user(void *to, const void __user *from, unsigned long size)
{
unsigned long ret = (unsigned long) -EFAULT;
int sz = __compiletime_object_size(to);
unsigned long ret = size;

if (likely(sz == -1 || sz >= size)) {
ret = ___copy_from_user(to, from, size);
Expand Down

0 comments on commit 6df1c17

Please sign in to comment.