]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
s390/crc32-vx: Fix checksum calculation for small sizes
authorChristian Borntraeger <borntraeger@de.ibm.com>
Wed, 3 Aug 2016 15:55:00 +0000 (17:55 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 8 Aug 2016 13:41:31 +0000 (15:41 +0200)
commit134a24cd895c5d138d639a0741ad27e389cd4562
treec832c8b62e5b75a67a3fe840f0b174657e8ce977
parentbf47dc572aaf53c3f2311c71e03ec01be3131fd6
s390/crc32-vx: Fix checksum calculation for small sizes

The current prealign logic will fail for sizes < alignment,
as the new datalen passed to the vector function is smaller
than zero. Being a size_t this gets wrapped to a huge
number causing memory overruns and wrong data.

Let's add an early exit if the size is smaller than the minimal
size with alignment. This will also avoid calling the software
fallback twice for all sizes smaller than the minimum size
(prealign + remaining)

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Fixes: f848dbd3bc1a ("s390/crc32-vx: add crypto API module for optimized CRC-32 algorithms")
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/crypto/crc32-vx.c