Skip to content

Commit 66db3fe

Browse files
changqin-tangH. Peter Anvin
authored andcommitted
x86-64: Fix the failure case in copy_user_handle_tail()
The increment of "to" in copy_user_handle_tail() will have incremented before a failure has been noted. This causes us to skip a byte in the failure case. Only do the increment when assured there is no failure. Signed-off-by: CQ Tang <cq.tang@intel.com> Link: http://lkml.kernel.org/r/20130318150221.8439.993.stgit@phlsvslse11.ph.intel.com Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Cc: <stable@vger.kernel.org>
1 parent a937536 commit 66db3fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/lib/usercopy_64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
7474
char c;
7575
unsigned zero_len;
7676

77-
for (; len; --len) {
77+
for (; len; --len, to++) {
7878
if (__get_user_nocheck(c, from++, sizeof(char)))
7979
break;
80-
if (__put_user_nocheck(c, to++, sizeof(char)))
80+
if (__put_user_nocheck(c, to, sizeof(char)))
8181
break;
8282
}
8383

0 commit comments

Comments
 (0)