From patchwork Fri Sep 16 12:07:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?T25kcmVqIE1vc27DocSNZWs=?= X-Patchwork-Id: 9335619 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 6E892608A0 for ; Fri, 16 Sep 2016 12:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6052929F6E for ; Fri, 16 Sep 2016 12:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5400229F73; Fri, 16 Sep 2016 12:08:08 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D10B629F74 for ; Fri, 16 Sep 2016 12:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755664AbcIPMH5 (ORCPT ); Fri, 16 Sep 2016 08:07:57 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34099 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934741AbcIPMHm (ORCPT ); Fri, 16 Sep 2016 08:07:42 -0400 Received: by mail-oi0-f68.google.com with SMTP id v62so2989918oig.1 for ; Fri, 16 Sep 2016 05:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:cc; bh=j0PJf+niVLnK2zeNDBqIPTxsCQQGFdwCNUtKbdCpiSk=; b=wBn9P+pRmeGPUniwzLL8isJUjlw+QvDr2Ytd7i8OcgD6Va2QyDhhqsTGSTy0Jc1X/Y gh2sSHYB30LwYM2nGQCrNWWtfBmjUjQZJwARC+5jHbePGKDgNGckbgiBhmFfHjxMS4pV P2UHtq+tiBQUuy//5GdzHP8jyLax5U4sMIUIlFrSeJH637hLOCjxhMfjb6jk1XYMKhh4 aDkzbeWlWm1NaT9kKEAjn+NPQNXyONqEj9Dg5ba4WMAKsjyJ1+MlV6NjT7xH+bgD3/eX KOkFiUCKcBQqeChs/LRZ6O7nfhxQv6AuF16fLiYU5YEGAEY0OFVM3jdGkJOzldJkX5Kh UXqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=j0PJf+niVLnK2zeNDBqIPTxsCQQGFdwCNUtKbdCpiSk=; b=Pam97e4M3mYDgZiIpk/XAzUWzIPTVOd3FxNsIMuOdoL8ILRDcWc53UO4kzlFzojR/L n9FQeTE8o01G2qFCNJDbaove6HdxeS6HGcQ9yUiSAGSiILlAWkVp370um8kEMMZhZKeJ VMotaXvWcmZNelK0B7pNfskDUWK3BnnDo/IbYaG/e0HnpMI1wl0W4m3wnxRcGkF500lz MSFwoXSl5YuBW0ntUMYz/LTY9+ap3Bb3Tg9lM/VeI77dTj6z/vN3mpeMhVxcrCxKEERG 5ZXvIGDuPDVXpMynEU8XxWOmnIJx2Qga18P3hFdaEIUq62YVmsGETiutJnr82h6dgdPN uTPw== X-Gm-Message-State: AE9vXwOGsAn0URnKVveka8WP1hPr8IBzK1KzXUyWs1m3pcmN6e11agubyifchHSfRpMr+vl1jzbhAKPX2MzP3Q== X-Received: by 10.157.11.161 with SMTP id 30mr11398506oth.113.1474027662046; Fri, 16 Sep 2016 05:07:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.4.208 with HTTP; Fri, 16 Sep 2016 05:07:40 -0700 (PDT) From: =?UTF-8?B?T25kcmVqIE1vc27DocSNZWs=?= Date: Fri, 16 Sep 2016 14:07:40 +0200 Message-ID: Subject: [PATCH] crypto: gcm - Fix IV buffer size in crypto_gcm_setkey To: Herbert Xu Cc: linux-crypto@vger.kernel.org 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 The cipher block size for GCM is 16 bytes, and thus the CTR transform used in crypto_gcm_setkey() will also expect a 16-byte IV. However, the code currently reserves only 8 bytes for the IV, causing an out-of-bounds access in the CTR transform. This patch fixes the issue by setting the size of the IV buffer to 16 bytes. Fixes: 84c911523020 ("[CRYPTO] gcm: Add support for async ciphers") Signed-off-by: Ondrej Mosnacek --- I randomly noticed this while going over igcm.c for an unrelated reason. It seems the wrong buffer size never caused any noticeable problems (it's been there since 2007), but it should be corrected nonetheless... crypto/gcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/gcm.c b/crypto/gcm.c index 70a892e8..f624ac9 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -117,7 +117,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, struct crypto_skcipher *ctr = ctx->ctr; struct { be128 hash; - u8 iv[8]; + u8 iv[16]; struct crypto_gcm_setkey_result result;