]> 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)
commite53f92bb04c219cd420c65c15de8f33d316cfa3c
tree7be6dcc962f1b596b3d0ad6ed3e34439c71fae91
parentc341964b73624317789e886f6e6272b67d4e3877
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