]> git.baikalelectronics.ru Git - 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)
commit73097011a215bc5c580d0a9107d031238b3e671d
tree7be6dcc962f1b596b3d0ad6ed3e34439c71fae91
parentc9b41d922904f7f691b4a1f8e586e881064f639e
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