linux/drivers/crypto
Jan Stancek d3392f41f6 crypto: nx - respect sg limit bounds when building sg lists for SHA
Commit 000851119e changed sha256/512 update functions to
pass more data to nx_build_sg_list(), which ends with
sg list overflows and usually with update functions failing
for data larger than max_sg_len * NX_PAGE_SIZE.

This happens because:
- both "total" and "to_process" are updated, which leads to
  "to_process" getting overflowed for some data lengths
  For example:
    In first iteration "total" is 50, and let's assume "to_process"
    is 30 due to sg limits. At the end of first iteration "total" is
    set to 20. At start of 2nd iteration "to_process" overflows on:
      to_process = total - to_process;
- "in_sg" is not reset to nx_ctx->in_sg after each iteration
- nx_build_sg_list() is hitting overflow because the amount of data
  passed to it would require more than sgmax elements
- as consequence of previous item, data stored in overflowed sg list
  may no longer be aligned to SHA*_BLOCK_SIZE

This patch changes sha256/512 update functions so that "to_process"
respects sg limits and never tries to pass more data to
nx_build_sg_list() to avoid overflows. "to_process" is calculated
as minimum of "total" and sg limits at start of every iteration.

Fixes: 000851119e ("crypto: nx - Fix SHA concurrence issue and sg
		      limit bounds")
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Cc: stable@vger.kernel.org
Cc: Leonidas Da Silva Barbosa <leosilva@linux.vnet.ibm.com>
Cc: Marcelo Henrique Cerri <mhcerri@linux.vnet.ibm.com>
Cc: Fionnuala Gunter <fin@linux.vnet.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2015-08-11 22:02:57 +08:00
..
amcc
caam Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-06-22 21:04:48 -07:00
ccp Power management and ACPI material for v4.2-rc1 2015-06-23 14:18:07 -07:00
marvell genalloc: rename of_get_named_gen_pool() to of_gen_pool_get() 2015-06-30 19:45:01 -07:00
nx crypto: nx - respect sg limit bounds when building sg lists for SHA 2015-08-11 22:02:57 +08:00
qat crypto: qat - Fix invalid synchronization between register/unregister sym algs 2015-07-23 18:09:17 +08:00
qce
ux500 crypto: drivers - Fix Kconfig selects 2015-06-18 14:45:36 +08:00
vmx Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-06-22 21:04:48 -07:00
Kconfig crypto: marvell/cesa - remove COMPILE_TEST dependency 2015-06-22 15:49:48 +08:00
Makefile crypto: marvell/cesa - add a new driver for Marvell's CESA 2015-06-19 22:18:03 +08:00
atmel-aes-regs.h
atmel-aes.c
atmel-sha-regs.h
atmel-sha.c
atmel-tdes-regs.h
atmel-tdes.c
bfin_crc.c
bfin_crc.h
geode-aes.c
geode-aes.h
hifn_795x.c
img-hash.c
ixp4xx_crypto.c crypto: ixp4xx - Remove bogus BUG_ON on scattered dst buffer 2015-07-23 18:09:18 +08:00
mv_cesa.c crypto: marvell/cesa - another fix up for of_get_named_gen_pool() rename 2015-07-03 11:37:02 -07:00
mv_cesa.h
mxs-dcp.c
n2_asm.S
n2_core.c Merge branch 'mvebu/drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc 2015-06-19 22:07:07 +08:00
n2_core.h
omap-aes.c
omap-des.c crypto: omap-des - Fix unmapping of dma channels 2015-07-06 16:20:37 +08:00
omap-sham.c
padlock-aes.c
padlock-sha.c
picoxcell_crypto.c crypto: picoxcell - Update to the current clk API 2015-06-21 19:59:22 +08:00
picoxcell_crypto_regs.h
s5p-sss.c
sahara.c crypto: sahara - propagate the error on clk_disable_unprepare() failure 2015-06-21 19:59:28 +08:00
talitos.c
talitos.h