Message ID | 20180802225152.19194-2-keescook@chromium.org (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Mike Snitzer |
Headers | show
Return-Path: <dm-devel-bounces@redhat.com> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BBA615E9 for <patchwork-dm-devel@patchwork.kernel.org>; Thu, 2 Aug 2018 22:52:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECB7D2C4C2 for <patchwork-dm-devel@patchwork.kernel.org>; Thu, 2 Aug 2018 22:52:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0D702C4E8; Thu, 2 Aug 2018 22:52:09 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 823302C4C2 for <patchwork-dm-devel@patchwork.kernel.org>; Thu, 2 Aug 2018 22:52:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BD2130832D0; Thu, 2 Aug 2018 22:52:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEF5510694D0; Thu, 2 Aug 2018 22:52:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5A30A18052EA; Thu, 2 Aug 2018 22:52:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w72Mq3VX026033 for <dm-devel@listman.util.phx.redhat.com>; Thu, 2 Aug 2018 18:52:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 71FFB7C121; Thu, 2 Aug 2018 22:52:03 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 674587BB43 for <dm-devel@redhat.com>; Thu, 2 Aug 2018 22:52:00 +0000 (UTC) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B21CF4E90C for <dm-devel@redhat.com>; Thu, 2 Aug 2018 22:51:59 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id a11-v6so1888381pgw.6 for <dm-devel@redhat.com>; Thu, 02 Aug 2018 15:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4w4IN2J6dONrrlVeO1+L0Kz9qBIwIaC7ttYkBFQeQFw=; b=MJPtM5DrXi71NqaWEQYItiJlS3TD+nNAyTVAZSz56FSXdi41JPXEIZCHRfaKPO4EGa r9bnOJ8j0gTaHlb1zSUOXZYTYqTmHxwiIH5BGkUWd3Jcc5cQZ/Yq23cOPaClZMMODbr/ CojOQODYnJ/R98Ahr+wnJbTn5SrM8+olatYVs= 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=4w4IN2J6dONrrlVeO1+L0Kz9qBIwIaC7ttYkBFQeQFw=; b=ZjWnS+f48d7xyFFjzZX0UypaWPzC69Ga1CL2N9jnqTI1g7WgK25YMOe483u0oVvKlu bmSt2TsDDy5irDIcHMNCgaSvCyqgiUMR3/pUdH91WjxfB8WxYtWxbe2piEvn28b/3qwc ApjwYHbGrsFBo7CkHEvMKYLD5l9MV4aVtzyUkE/g897g3YFGUUDmH6O1ietFJ00cTqUY Rx9cRv957JLJoJqsYbkhQZ6tQCUIyOtPzF3dRUgDJwqnXdTaHyQ8W3dWdOXYFhd2B/sl s7rnisarTY4llNxvjr8ttDdctQO6+tb2/VBKYbUAzwqEsWaW/630CYRcENlNLdOMtzvd Y84g== X-Gm-Message-State: AOUpUlHzIWqCszqDX4eLUPM/WuhseXi4S4rW8vktgglZuJx8dkPEsAbB aawYCNH1/QkGqPKjpO0p5AtPtw== X-Google-Smtp-Source: AAOMgpfS7uWJ2m2fnCd3q5O44WlAj38sQsrNquS+SSvsE+4QOZ9ZAOZxHfW/J5fqtyqnrkchc4RsdA== X-Received: by 2002:a62:cac5:: with SMTP id y66-v6mr1437334pfk.187.1533250319247; Thu, 02 Aug 2018 15:51:59 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id 5-v6sm4465319pgc.86.2018.08.02.15.51.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Aug 2018 15:51:56 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Herbert Xu <herbert@gondor.apana.org.au> Date: Thu, 2 Aug 2018 15:51:44 -0700 Message-Id: <20180802225152.19194-2-keescook@chromium.org> In-Reply-To: <20180802225152.19194-1-keescook@chromium.org> References: <20180802225152.19194-1-keescook@chromium.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 02 Aug 2018 22:51:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 02 Aug 2018 22:51:59 +0000 (UTC) for IP:'209.85.215.195' DOMAIN:'mail-pg1-f195.google.com' HELO:'mail-pg1-f195.google.com' FROM:'keescook@chromium.org' RCPT:'' X-RedHat-Spam-Score: -0.131 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.195 mail-pg1-f195.google.com 209.85.215.195 mail-pg1-f195.google.com <keescook@chromium.org> X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu <giovanni.cabiddu@intel.com>, linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>, Mike Snitzer <snitzer@redhat.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, Tudor-Dan Ambarus <tudor.ambarus@microchip.com>, Will Deacon <will.deacon@arm.com>, Matthew Wilcox <mawilcox@microsoft.com>, Arnd Bergmann <arnd@arndb.de>, "David S. Miller" <davem@davemloft.net>, dm-devel@redhat.com, Geert Uytterhoeven <geert@linux-m68k.org>, David Woodhouse <dwmw@amazon.co.uk>, qat-linux@intel.com, Andrew Morton <akpm@linux-foundation.org>, Thomas Gleixner <tglx@linutronix.de>, Alasdair Kergon <agk@redhat.com>, linux-crypto@vger.kernel.org Subject: [dm-devel] [PATCH v7 1/9] crypto: xcbc: Remove VLA usage X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development <dm-devel.redhat.com> List-Unsubscribe: <https://www.redhat.com/mailman/options/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=unsubscribe> List-Archive: <https://www.redhat.com/archives/dm-devel> List-Post: <mailto:dm-devel@redhat.com> List-Help: <mailto:dm-devel-request@redhat.com?subject=help> List-Subscribe: <https://www.redhat.com/mailman/listinfo/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 02 Aug 2018 22:52:08 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
crypto: Remove VLA usage
|
expand
|
diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 25c75af50d3f..c055f57fab11 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -57,15 +57,17 @@ struct xcbc_desc_ctx { u8 ctx[]; }; +#define XCBC_BLOCKSIZE 16 + static int crypto_xcbc_digest_setkey(struct crypto_shash *parent, const u8 *inkey, unsigned int keylen) { unsigned long alignmask = crypto_shash_alignmask(parent); struct xcbc_tfm_ctx *ctx = crypto_shash_ctx(parent); - int bs = crypto_shash_blocksize(parent); u8 *consts = PTR_ALIGN(&ctx->ctx[0], alignmask + 1); int err = 0; - u8 key1[bs]; + u8 key1[XCBC_BLOCKSIZE]; + int bs = sizeof(key1); if ((err = crypto_cipher_setkey(ctx->child, inkey, keylen))) return err; @@ -212,7 +214,7 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb) return PTR_ERR(alg); switch(alg->cra_blocksize) { - case 16: + case XCBC_BLOCKSIZE: break; default: goto out_put_alg;
In the quest to remove all stack VLA usage from the kernel[1], this uses the maximum blocksize and adds a sanity check. For xcbc, the blocksize must always be 16, so use that, since it's already being enforced during instantiation. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook <keescook@chromium.org> --- crypto/xcbc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)