]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
crypto: testmgr - Allocate only the required output size for hash tests
authorAndrew Lutomirski <luto@kernel.org>
Tue, 10 Jan 2017 23:24:46 +0000 (15:24 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 12 Jan 2017 16:26:45 +0000 (00:26 +0800)
commite93acd6f6778825a4e0b5a1a9b70324bf901d516
tree7be6dcc962f1b596b3d0ad6ed3e34439c71fae91
parentf283148a0774e9b2de5ae4b42bb7dff50410f8cc
crypto: testmgr - Allocate only the required output size for hash tests

There are some hashes (e.g. sha224) that have some internal trickery
to make sure that only the correct number of output bytes are
generated.  If something goes wrong, they could potentially overrun
the output buffer.

Make the test more robust by allocating only enough space for the
correct output size so that memory debugging will catch the error if
the output is overrun.

Tested by intentionally breaking sha224 to output all 256
internally-generated bits while running on KASAN.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c