Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp7193061imm; Tue, 24 Jul 2018 09:54:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+pQTemeVxFZ0yg4wWmzSDX87CAEB05g8XHoPqo7HUWhMpptVicv3MEROyrAH3qiyEGVTC X-Received: by 2002:a63:460d:: with SMTP id t13-v6mr16866792pga.201.1532451284256; Tue, 24 Jul 2018 09:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532451284; cv=none; d=google.com; s=arc-20160816; b=xz1Xfgsuw5+R1zeTAvd2/c6KECoEqsh5ZcSTZg+Ycxe/NGraZV75m83MTPJfS3zT+d gN/QzaAYORawlzzcyVfkywRsM+eDJFHCddc8d6r+frFCNBsH991UtiBxj9qEnrnpP9Aw TlLoJTJ0g6BYzwPrsG7X7TpphSbs3Eg0/zkFNStheoj0rvafXKcI3+NJBKZ6BHA07/xo hBrMarHx09DNCc32ofME1OPrl9E8bTnIhvrOnD8Aq5E0V2mzaSI6LxwkyMjGuevL/qce jHfgBBZU3afjx6Kg0Qe2/xuF3zlyXpG43A7mwlBbq8YkumGdzmE/dijuSTzIdipw9WOz +M4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4w4IN2J6dONrrlVeO1+L0Kz9qBIwIaC7ttYkBFQeQFw=; b=llziKWSoFbd69s4v69rAwV9pm05zqQtUMwxzzHmw93VI2vFPrahp2To3jWeSDAXENy qgEYFqxaO94Frd3olrJ3LccSP3GSfdCkcoq9v0Sl19zW5NVX9pwNY96OS7K+mm4XeNUc pHm6pVCtjbIPOfML3FEFeBvBvOvbYvTgoRV9oU6CIZ75fy8K+cAQHiLocAtqAPZ3Ta1J s2S1a1J16MM/G5pQxUc9wvZUZRu8qkF0y5Mvox82nPOq67oBWXH81MzMs/Vij1hBULq0 ZDr0OSydYns3bD84EMZpCiwZWuivDydyarTXsRk+S0SgmJjJ3901weuCume9RbjcUISr 3U7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KUe+Ljla; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si11258354pgg.84.2018.07.24.09.54.28; Tue, 24 Jul 2018 09:54:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KUe+Ljla; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388718AbeGXSA0 (ORCPT + 99 others); Tue, 24 Jul 2018 14:00:26 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:46011 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388442AbeGXR5F (ORCPT ); Tue, 24 Jul 2018 13:57:05 -0400 Received: by mail-pl0-f68.google.com with SMTP id j8-v6so1955675pll.12 for ; Tue, 24 Jul 2018 09:49:45 -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=KUe+LjlaQlS1O5ciNkx+mQgwWTRmPZ13UHy/USQfoyc0dAXMTwzk2Xx6qUc7AlF0O2 QiGXnGLkJwj+BaRXaUO015beIxRmiskoZ3V8mMejwoG8eJCaOM0zKqmuuA0SSSqaghC0 k1TppukdfSo15YKpxR2HelnJKmM6fpiatM8sk= 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=a/SOifGY3exHRBPGfn0kto88wH7djmPVjmW2o9lfX+jGeqbk63Bf/0/t8xEB/OCUrO 2OEFSXYXvsz8Kcaj7kScc6q9xGyGx6FUYudttrCM8DeZZDnvWQqSZ8POEM058hyJZAPI +dVUI1TYodtxK2isEXtGmlu2LHtC6wOjvESEnEbWw/dAEIfJcuAPUliFfG344gmrjVKJ hblE/GVjGjDOVB8zeFRvyXs+D6kXdX8OO1Sozq51qoY/frFowjFVntjIP31qjgMJHHhe a5GhC9KlNsxV6ksZAt4/9HkbTmTaBgfOqxJHXUD/RaYxIAwLMXHU/sS5y5jm/jL9Tge7 8MbQ== X-Gm-Message-State: AOUpUlErcDslcHNGyimD9CFm1uevRLm+xmu6KaQCRa9gwdLmX3/wQ++G wrF+BrnCb9uCwMx0xIWFHZ5XMg== X-Received: by 2002:a17:902:4203:: with SMTP id g3-v6mr17515330pld.315.1532450984795; Tue, 24 Jul 2018 09:49:44 -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 w13-v6sm2179184pgs.89.2018.07.24.09.49.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:49:42 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , Arnd Bergmann , Eric Biggers , "Gustavo A. R. Silva" , Alasdair Kergon , Rabin Vincent , Tim Chen , "Rafael J. Wysocki" , Pavel Machek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Philipp Reisner , Lars Ellenberg , Jens Axboe , Giovanni Cabiddu , Mike Snitzer , Paul Mackerras , Greg Kroah-Hartman , David Howells , Johannes Berg , Tudor-Dan Ambarus , Jia-Ju Bai , Andrew Morton , Geert Uytterhoeven , Josh Poimboeuf , David Woodhouse , Will Deacon , dm-devel@redhat.com, linux-pm@vger.kernel.org, linux-crypto@vger.kernel.org, drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, qat-linux@intel.com, linux-ppp@vger.kernel.org, netdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-afs@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 01/18] crypto: xcbc: Remove VLA usage Date: Tue, 24 Jul 2018 09:49:19 -0700 Message-Id: <20180724164936.37477-2-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180724164936.37477-1-keescook@chromium.org> References: <20180724164936.37477-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- crypto/xcbc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; -- 2.17.1