Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100084
b: refs/heads/master
c: 1129585
h: refs/heads/master
v: v3
  • Loading branch information
Vitaly Mayatskikh authored and Ingo Molnar committed Jul 9, 2008
1 parent 4263bdc commit 035c277
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: de989ef093623ab5259f885f30be699c431d4006
refs/heads/master: 1129585a08baf58582c0da91e572cb29e3179acf
23 changes: 23 additions & 0 deletions trunk/arch/x86/lib/usercopy_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,26 @@ unsigned long copy_in_user(void __user *to, const void __user *from, unsigned le
}
EXPORT_SYMBOL(copy_in_user);

/*
* Try to copy last bytes and clear the rest if needed.
* Since protection fault in copy_from/to_user is not a normal situation,
* it is not necessary to optimize tail handling.
*/
unsigned long
copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
{
char c;
unsigned zero_len;

for (; len; --len) {
if (__get_user_nocheck(c, from++, sizeof(char)))
break;
if (__put_user_nocheck(c, to++, sizeof(char)))
break;
}

for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
if (__put_user_nocheck(c, to++, sizeof(char)))
break;
return len;
}
3 changes: 3 additions & 0 deletions trunk/include/asm-x86/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,7 @@ static inline int __copy_from_user_inatomic_nocache(void *dst,
return __copy_user_nocache(dst, src, size, 0);
}

unsigned long
copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);

#endif /* __X86_64_UACCESS_H */

0 comments on commit 035c277

Please sign in to comment.