From patchwork Mon Jun 18 17:22:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10472395 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29588601D7 for ; Mon, 18 Jun 2018 17:25:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E0DA28AEB for ; Mon, 18 Jun 2018 17:25:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 011B728AFD; Mon, 18 Jun 2018 17:25:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA6C628AEB for ; Mon, 18 Jun 2018 17:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935127AbeFRRY7 (ORCPT ); Mon, 18 Jun 2018 13:24:59 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:43321 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934963AbeFRRY7 (ORCPT ); Mon, 18 Jun 2018 13:24:59 -0400 Received: by mail-pg0-f68.google.com with SMTP id a14-v6so7840959pgw.10 for ; Mon, 18 Jun 2018 10:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+2spVXx6yEuIx4fWknAoAPwnXHoD+IBHmI/uEmm8xHw=; b=O/emfW3Q7kO54PeH4UAVryJ/a07zaHNv5Nvw6ioaqPMweud+mdBZoDTTwZUGT2JBJm NbZd0uPPM2FeNwkXvjWPBd9hbmZP/+nnJAuY2JqBYUvujtkTJ/I1R2aq875HqdOo4vbt 2qRN5mTtSEIeenqOI/LCss07A5Uj50lc2hgWB9p1FyweeoyWfmFiJ2bC0Nhtka5qYzAk Yssl+Iy0UXg/MSTuSZGXpO6iJ2eQaZ9VZN/qwkedab/VATxyN0hUcsxaSADH8vZBtb6T oVnzyCCH0stSKNQCfcp3jNtUwvAzNsgKgQHzQVfzEkTARroGZc15xUm6lPWyv97AjRcC l7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+2spVXx6yEuIx4fWknAoAPwnXHoD+IBHmI/uEmm8xHw=; b=hWP5+zxEDUs5CpoapAsQqEZHVuy/TlNaZvb7f4JyRg/JmklaC43heId3m7+Q/sKWKF FR0+X/0dMUr28ZNmij6fHk4BlH2WRiSKNTXd4/sUH3aREv6ezLZW+tJaVOAmqsfS8c33 mrHTtqSYFwI/D6E9a5Dx3nAesPnUcB3v6TbEWk0aWsmaV8jUGpgpa6nI5V/H2wj71xN6 R/ZBo/7txU49CLbpC/XJZQia/2Halb0H8jySmJ5FwWkHhB4ILbAZbNI3xnSdHAPI41X3 pzsyimZ7I4U0piCew2h3v3Gel3HEmBBfzwWDOmCeyX4nRQZoq5YjVjfVUG2GSQVRV2WK SJdw== X-Gm-Message-State: APt69E1EuSD1e8qOzfLqdeeAsdsClVIxC4iT887SWJSiMDRHVh4I7txC aSsP/HVRS30pslhiuDzb0WDt2QBk X-Google-Smtp-Source: ADUXVKIT2TF13RiXaBFLOKtYxCuvbtX3xOLFmPNCt57hOCKxhiIVpLpDvJ2y8gm7Gviap0k3iCLIXg== X-Received: by 2002:a63:bf49:: with SMTP id i9-v6mr11935980pgo.342.1529342698213; Mon, 18 Jun 2018 10:24:58 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id k80-v6sm29812976pfa.168.2018.06.18.10.24.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 10:24:57 -0700 (PDT) From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: Shane Wang , Khazhismel Kumykov , Eric Biggers Subject: [PATCH 1/4] crypto: vmac - require a block cipher with 128-bit block size Date: Mon, 18 Jun 2018 10:22:37 -0700 Message-Id: <20180618172240.46651-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618172240.46651-1-ebiggers3@gmail.com> References: <20180618172240.46651-1-ebiggers3@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers 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: # v2.6.32+ Signed-off-by: Eric Biggers --- 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))