Skip to content

Commit

Permalink
x86-64: make csum_partial_copy_from_user() error handling consistent
Browse files Browse the repository at this point in the history
Al Viro pointed out that the x86-64 csum_partial_copy_from_user() is
somewhat confused about what it should do on errors, notably it mostly
clears the uncopied end result buffer, but misses that for the initial
alignment case.

All users should check for errors, so it's dubious whether the clearing
is even necessary, and Al also points out that we should probably clean
up the calling conventions, but regardless of any future changes to this
function, the fact that it is inconsistent is just annoying.

So make the __get_user() failure path use the same error exit as all the
other errors do.

Reported-by: Al Viro <[email protected]>
Cc: David Miller <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Nov 16, 2014
1 parent 5f01feb commit 3b91270
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions arch/x86/lib/csum-wrappers_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
while (((unsigned long)src & 6) && len >= 2) {
__u16 val16;

*errp = __get_user(val16, (const __u16 __user *)src);
if (*errp)
return isum;
if (__get_user(val16, (const __u16 __user *)src))
goto out_err;

*(__u16 *)dst = val16;
isum = (__force __wsum)add32_with_carry(
Expand Down

0 comments on commit 3b91270

Please sign in to comment.