Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp81416imm; Tue, 7 Aug 2018 14:20:44 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw6Yl9DRLU7Q/IBfl/WG4Va/n9a3a8AVpAP/rDlREY16c63I3fOXhwTSP5WzcqU4HtSBJGH X-Received: by 2002:a63:5204:: with SMTP id g4-v6mr83634pgb.274.1533676844253; Tue, 07 Aug 2018 14:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533676844; cv=none; d=google.com; s=arc-20160816; b=L64D3m+FUjKimnHZZExoUcm+PRpMHKjsusFw7kQrQBvR7RPCGVIQJbJ+E6X6oLLRL7 EBdtLY4O7z+afcVMkydJvY4yR29G8Zz2w4QX7uGd7L7iVjEUQ/oBpE1hQg1cADbDGeue NIfTLRh6KF9W9RLFAr2D49t1dhzHPVLy5KX4RInMTolhmc+ltH6xcvSJmkuRKJMlj0nO 7lW/SRJRIB+jn/C3hnzZzRT6e72prWoBFB0sVNdG1wQOFS5Povgr1ecofBIu4AO6Oc2r vUoVScjhAWgrVRM3CHHPLPDL7wlDPz0042M4QdnqduM1+fYpv001CwLgbHFDfYKyBHmS mAwQ== 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=EkyepxJYYg0je/b3NiaQiy2AjSlUjbqRT6E+F5UKQxDaRLkM2bnLll1+r0yrG+URMG ojS658PK/SpHGRDbQ076h7jU3dMr8yRVGWbm2Qp1jeKytfqFA55SnpbKchNimkUQ/4Iv MlAKtaoPY6krd5T7i8zpy6XsaNo81Mgr0RdIMr61eTWI/8jEpwRMu+5ZuvcZo9lXaGDR bzQvwl9cqCmsHLQpaRScM8ihrL7pI1ZucrnLKDIm1s2R9Tuutmdc/Bt5e3xdIQ/g9LQP ClhnfI/9r++kXj5Mc4p0kvwVH3MD9UnAsnfgE0piQHWkUCYlymjB4wICKPcDkVfKhXkP Lf8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="g5V/+UNG"; 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=REJECT sp=REJECT 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 w16-v6si1677509ply.462.2018.08.07.14.20.29; Tue, 07 Aug 2018 14:20: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="g5V/+UNG"; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727155AbeHGXfK (ORCPT + 99 others); Tue, 7 Aug 2018 19:35:10 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38493 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeHGXfJ (ORCPT ); Tue, 7 Aug 2018 19:35:09 -0400 Received: by mail-pg1-f195.google.com with SMTP id k3-v6so38229pgq.5 for ; Tue, 07 Aug 2018 14:18:50 -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=g5V/+UNGYEfT8p5zd7CvV11zi8FsLPtOPGoByy0g0pK9yXQXBq6BBwKQ/BitwRJ/Kx NtQyPpWFPVCZBQdL7upAG2e+jOOdzhKhQwj54mO+9G0XvrNxFqqH0kwxOL6a8PeBgRhp hRdbvwuLOmZJGN1L98PblisEO6fQtcOtYkGdI= 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=G7Q5TQtaiiwmCDBuuHz7Rh9pOp79ytyWjNS47RkpDXOfdBe4V/V1nc87O3JachZdSe PDpH9oOzg0CljZyTDTsZr1FLXVJnj70rD83LfTrjCaqN0xU+ZqzX+H80KRXoU4qYjQrP fjIBDMxFiN6FinD2M0v2ByN2raXZ8DnUA2UIUp7W2H8K3rw4jSIpdgTtBa1Z8mg9S5Vw qQbdvSbY39xe5dlY+CiD5KE1LQrFiFuTFSaNOsdSNR8ybVhLvYSZnyI/BX+S+J+61POC u9UEElHGdREW4/ps+SMyBBMhK08OueWGSOawPvQNsFjeu6X6nlRPXz+IxeBbmerBLoFo UaAg== X-Gm-Message-State: AOUpUlEXwpwLMvzrQTEsoPgLRvC26ju1Vlv+8jznavv0SitvdspU54s3 6Qm8UOVe6uo0j56gdYmY10HFiA== X-Received: by 2002:a62:c00c:: with SMTP id x12-v6mr86359pff.216.1533676730040; Tue, 07 Aug 2018 14:18:50 -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 o3-v6sm2262323pgp.3.2018.08.07.14.18.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 14:18:46 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , Eric Biggers , Ard Biesheuvel , Giovanni Cabiddu , Alasdair Kergon , Mike Snitzer , Tudor-Dan Ambarus , Andrew Morton , Thomas Gleixner , Geert Uytterhoeven , Arnd Bergmann , Will Deacon , Rasmus Villemoes , David Woodhouse , Matthew Wilcox , "David S. Miller" , "Gustavo A. R. Silva" , linux-crypto@vger.kernel.org, dm-devel@redhat.com, qat-linux@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v8 1/9] crypto: xcbc: Remove VLA usage Date: Tue, 7 Aug 2018 14:18:35 -0700 Message-Id: <20180807211843.47586-2-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180807211843.47586-1-keescook@chromium.org> References: <20180807211843.47586-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