Commit 24ab54cb authored by Ollie Wild's avatar Ollie Wild Committed by Paul Mundt

sh: Fix TCP payload csum bug in csum_partial_copy_generic().

There's a bug in the Hitachi SuperH csum_partial_copy_generic()
implementation.  If the supplied length is 1 (and several alignment
conditions are met), the function immediately branches to label 4.
However, the assembly at label 4 expects the length to be stored in
register r2.  Since this has not occurred, subsequent behavior is
undefined.

This can cause bad payload checksums in TCP connections.

I've fixed the problem by initializing register r2 prior to the branch
instruction.
Signed-off-by: default avatarOllie Wild <aaw@rincewind.tv>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 8b395265
...@@ -202,8 +202,9 @@ ENTRY(csum_partial_copy_generic) ...@@ -202,8 +202,9 @@ ENTRY(csum_partial_copy_generic)
cmp/pz r6 ! Jump if we had at least two bytes. cmp/pz r6 ! Jump if we had at least two bytes.
bt/s 1f bt/s 1f
clrt clrt
add #2,r6 ! r6 was < 2. Deal with it.
bra 4f bra 4f
add #2,r6 ! r6 was < 2. Deal with it. mov r6,r2
3: ! Handle different src and dest alignments. 3: ! Handle different src and dest alignments.
! This is not common, so simple byte by byte copy will do. ! This is not common, so simple byte by byte copy will do.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment