From: Eric Biggers <ebigg...@google.com>

The VMAC template assumes the block cipher has a 128-bit block size, but
it failed to check for that.  Thus it was possible to instantiate it
using a 64-bit block size cipher, e.g. "vmac(cast5)", causing
uninitialized memory to be used.

Add the needed check when instantiating the template.

Fixes: f1939f7c5645 ("crypto: vmac - New hash algorithm for intel_txt support")
Cc: <sta...@vger.kernel.org> # v2.6.32+
Signed-off-by: Eric Biggers <ebigg...@google.com>
---
 crypto/vmac.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/crypto/vmac.c b/crypto/vmac.c
index df76a816cfb2..3034454a3713 100644
--- a/crypto/vmac.c
+++ b/crypto/vmac.c
@@ -655,6 +655,10 @@ static int vmac_create(struct crypto_template *tmpl, 
struct rtattr **tb)
        if (IS_ERR(alg))
                return PTR_ERR(alg);
 
+       err = -EINVAL;
+       if (alg->cra_blocksize != 16)
+               goto out_put_alg;
+
        inst = shash_alloc_instance("vmac", alg);
        err = PTR_ERR(inst);
        if (IS_ERR(inst))
-- 
2.18.0.rc1.244.gcf134e6275-goog

Reply via email to