Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: aesni - ctr_crypt() use min() instead of min_t()

min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
and so cannot discard significant bits.

In this case the 'unsigned long' value is small enough that the result
is ok.

Detected by an extra check added to min_t().

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

David Laight and committed by
Herbert Xu
6c5d5b6d 680cd3e2

+1 -2
+1 -2
arch/x86/crypto/aesni-intel_glue.c
··· 693 693 * operation into two at the point where the overflow 694 694 * will occur. After the first part, add the carry bit. 695 695 */ 696 - p1_nbytes = min_t(unsigned int, nbytes, 697 - (nblocks - ctr64) * AES_BLOCK_SIZE); 696 + p1_nbytes = min(nbytes, (nblocks - ctr64) * AES_BLOCK_SIZE); 698 697 (*ctr64_func)(key, walk.src.virt.addr, 699 698 walk.dst.virt.addr, p1_nbytes, le_ctr); 700 699 le_ctr[0] = 0;