Skip to content

Commit 4408ba7

Browse files
groeckhdeller
authored andcommitted
parisc: Fix csum_ipv6_magic on 32-bit systems
Calculating the IPv6 checksum on 32-bit systems missed overflows when adding the proto+len fields into the checksum. This results in the following unit test failure. # test_csum_ipv6_magic: ASSERTION FAILED at lib/checksum_kunit.c:506 Expected ( u64)csum_result == ( u64)expected, but ( u64)csum_result == 46722 (0xb682) ( u64)expected == 46721 (0xb681) not ok 5 test_csum_ipv6_magic This is probably rarely seen in the real world because proto+len are usually small values which will rarely result in overflows when calculating the checksum. However, the unit test code uses large values for the length field, causing the test to fail. Fix the problem by adding the missing carry into the final checksum. Cc: Palmer Dabbelt <palmer@rivosinc.com> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Charlie Jenkins <charlie@rivosinc.com> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent a2abae8 commit 4408ba7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/parisc/include/asm/checksum.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
163163
" ldw,ma 4(%2), %7\n" /* 4th daddr */
164164
" addc %6, %0, %0\n"
165165
" addc %7, %0, %0\n"
166-
" addc %3, %0, %0\n" /* fold in proto+len, catch carry */
166+
" addc %3, %0, %0\n" /* fold in proto+len */
167+
" addc 0, %0, %0\n" /* add carry */
167168

168169
#endif
169170
: "=r" (sum), "=r" (saddr), "=r" (daddr), "=r" (len),

0 commit comments

Comments
 (0)