s390/checksum: Fix csum_partial() without vector facility
Vasily Gorbik
maintainerPATCH 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().
--- arch/s390/lib/csum-partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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, __wif (!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
Quoted 19 lines · Vasily Gorbik
Currently
csum_partial()callscsum_copy()with copy=false and dst=NULL. On machines without the vector facility,csum_copy()falls back tocksm(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()")Signed-off-by Vasily Gorbik <[email protected]>--- arch/s390/lib/csum-partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/lib/csum-partial.c +0
-0
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, __wif (!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.
Quoted 5 lines · Vasily Gorbik
Currently
csum_partial()callscsum_copy()with copy=false and dst=NULL. On machines without the vector facility,csum_copy()falls back tocksm(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()")Signed-off-by Vasily Gorbik <[email protected]>--- arch/s390/lib/csum-partial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied