Skip to content

Commit

Permalink
MIPS: Fix special case in 64 bit IP checksumming.
Browse files Browse the repository at this point in the history
For certain arguments such as saddr = 0xc0a8fd60, daddr = 0xc0a8fda1,
len = 80, proto = 17, sum = 0x7eae049d there will be a carry when
folding the intermediate 64 bit checksum to 32 bit but the code doesn't
add the carry back to the one's complement sum, thus an incorrect result
will be generated.

Reported-by: Mark Zhang <[email protected]>
Signed-off-by: Ralf Baechle <[email protected]>
Reviewed-by: James Hogan <[email protected]>
Cc: [email protected]
Signed-off-by: James Hogan <[email protected]>
  • Loading branch information
ralfbaechle authored and James Hogan committed Feb 17, 2017
1 parent 4da3273 commit 66fd848
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/mips/include/asm/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
" daddu %0, %4 \n"
" dsll32 $1, %0, 0 \n"
" daddu %0, $1 \n"
" sltu $1, %0, $1 \n"
" dsra32 %0, %0, 0 \n"
" addu %0, $1 \n"
#endif
" .set pop"
: "=r" (sum)
Expand Down

0 comments on commit 66fd848

Please sign in to comment.