• Andrew Lutomirski's avatar
    crypto: testmgr - Allocate only the required output size for hash tests · e93acd6f
    Andrew Lutomirski authored
    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: default avatarAndy Lutomirski <luto@kernel.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    e93acd6f
testmgr.c 90.9 KB