Skip to contentSkip to conversation

s390/checksum: Fix csum_partial() without vector facility

PATCH Applied Vasily Gorbik 2 participants 3 messages Jul 8 – Jul 9 s390

lore
Share & tools
lore

Vasily Gorbik

author maintainer
#0 lore raw

PATCH 1/1 s390/checksum: Fix csum_partial() without vector facility

Currently csum_partial() calls csum_copy() with copy=false and dst=NULL. On machines without the vector facility, csum_copy() falls back to cksm(dst, ...), causing the checksum to be calculated from address zero instead of the source buffer.

The VX implementation already checksums data loaded from src. Make the fallback do the same by passing src to cksm().

Fixes dcd3e1de9d17 ("s390/checksum: provide csum_partial_copy_nocheck()")
---
 arch/s390/lib/csum-partial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/lib/csum-partial.c +1 -1
index 458abd9bac70..9d74ceff136c 100644
@@ -23,7 +23,7 @@ static __always_inline __wsum csum_copy(void *dst, const void *src, int len, __w
 	if (!cpu_has_vx()) {
 		if (copy)
 			memcpy(dst, src, len);
-		return cksm(dst, len, sum);
+		return cksm(src, len, sum);
 	}
 	kernel_fpu_begin(&vxstate, KERNEL_VXR_V16V23);
 	fpu_vlvgf(16, (__force u32)sum, 1);
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Vasily Gorbik

Currently csum_partial() calls csum_copy() with copy=false and dst=NULL. On machines without the vector facility, csum_copy() falls back to cksm(dst, ...), causing the checksum to be calculated from address zero instead of the source buffer.

The VX implementation already checksums data loaded from src. Make the fallback do the same by passing src to cksm().

Fixes dcd3e1de9d17 ("s390/checksum: provide csum_partial_copy_nocheck()")
---
 arch/s390/lib/csum-partial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/lib/csum-partial.c +0 -0
index 458abd9bac70..9d74ceff136c 100644

arch/s390/lib/csum-partial.c static __always_inline __wsum csum_copy(void *dst, const void *src, int len, __w · line 26

Quoted 5 lines
arch/s390/lib/csum-partial.c +1 -1
@@ -23,7 +23,7 @@ static __always_inline __wsum csum_copy(void *dst, const void *src, int len, __w
 	if (!cpu_has_vx()) {
 		if (copy)
 			memcpy(dst, src, len);
-		return cksm(dst, len, sum);
+		return cksm(src, len, sum);

But at least that also tells us that this code never worked on pre z13.

author maintainer Applied
#2 lore raw
In reply to Vasily Gorbik
Quoted 5 lines · Vasily Gorbik

Currently csum_partial() calls csum_copy() with copy=false and dst=NULL. On machines without the vector facility, csum_copy() falls back to cksm(dst, ...), causing the checksum to be calculated from address zero instead of the source buffer.

Quoted 8 lines

The VX implementation already checksums data loaded from src. Make the fallback do the same by passing src to cksm().

Fixes dcd3e1de9d17 ("s390/checksum: provide csum_partial_copy_nocheck()")
---
 arch/s390/lib/csum-partial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied