Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp81099imm; Tue, 7 Aug 2018 14:20:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzOoQdZ0Sp7oxekxqDL2RfGA2bML/4fnXH2mOY30NHRHtOt7VvoQJoV/AVg0iuHvQJwXpHj X-Received: by 2002:a62:4083:: with SMTP id f3-v6mr66912pfd.229.1533676820785; Tue, 07 Aug 2018 14:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533676820; cv=none; d=google.com; s=arc-20160816; b=zeGoGAfXtfsmI4OuOQusUofkJNprsRm8zEEf5isMT1Y/WMjErtMj2yivtCtOtpxE29 fUMVktv5TeW+N87EuuzeC5WO0CYq5C4U5CJE3ULXGR39wtvOwBJ1njiAmYsA7RAg4J+7 4HgopZcD81ok3OenocqvSIbpXia9MNTxrGYGu2mcUqeBsKgywZAgkwXlYAz8RJBnMh4T nw8FAJemwvGC6tLIR4W084rauvFR1aH5KBYrWYJCmbBHrtykqFKYgU4PDd4Eli/hodHd fczW3qcUlfYdjdU5cNfFIIccWxq6a3tm5mZR4HRStWZTDI0QjQEGI1ueoTq6dz8iSFdz 0Uww== 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=BYgigRdBSanSiafl9f2cJhj28CjRYh2SZJXlKmlCU5M=; b=fh4aKruXdb7TetDIMns7WV5yP1n4FDAaLv1fI7QOUiAOopk5VZGjvWncBo6o9Xo5OA 3doAQG29tS/7dUZc7mkGFoVqzELezLohpk/pPJ3QU8p8wU2Ct2Tqyehy8uJYa3kyLgBS hrLe+Kc4GrkgubDEmflFJ7akDa10B90Qjtr9/WQfPkTJMt99NZ8AVbIm9rs72CXVF11j RpRvOOVM9ITp2i7d/VBFPNOqqJLXpe69CVz2B+QAZqfNfZzIm+3HOnXEmzP6aP1BXP9J m+sfxZ1QzaKqqZRECaw+gglvfTbTjAL7mqu3IrKIM972tFyHQgan2M6twuGJsgGvY3wB JJ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bwj5h6LG; 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 e125-v6si2244117pgc.424.2018.08.07.14.20.02; Tue, 07 Aug 2018 14:20:20 -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=bwj5h6LG; 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 S1727288AbeHGXfO (ORCPT + 99 others); Tue, 7 Aug 2018 19:35:14 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41537 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeHGXfN (ORCPT ); Tue, 7 Aug 2018 19:35:13 -0400 Received: by mail-pg1-f195.google.com with SMTP id z8-v6so31290pgu.8 for ; Tue, 07 Aug 2018 14:18:54 -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=BYgigRdBSanSiafl9f2cJhj28CjRYh2SZJXlKmlCU5M=; b=bwj5h6LGT5ACmPMZYi0LG2N5D3F3SAfB8C3avF/CBbiNS2h591ypLOSakoTAgXKWvx +KgSLVleYXJfmoNPYhoNW5ZtD3uU9iNTmljRuHQ4YceMx9t9s5sj7k1Gf13Dev+AhMkp RJ4rdVkBDipUY4OISqzdenyjqwZzZ5r2punaU= 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=BYgigRdBSanSiafl9f2cJhj28CjRYh2SZJXlKmlCU5M=; b=C3ez/Vs4Uc09BTYKNgLr0ysV9sq91KCSq3GbKPiqxWqZ3M1TsIb/HrNIUcSGnDtgQq +m398kzvvKE+vU8GnqVYLozQYNvAMGApv1YOyWLwYwiZ3kWVhl9O/Z0l/DjZDvKgVzvi Jsfd8L2VzFf5nG635+43eZZbPQZh9pOaqnMCnKDo9b53P7Z4EivEKbuu7508Pc1xwTut yAu8NKDCt8RCBIsBWf9Mx19As5eAGOz1GthP7OLJVuVqEJTf86mrbEmqNlPVVFHWUImi Z82klr3kZsz929yNoqplxGHiUgaO2pEUdfGr9XeAP3CvCvHmlFukaT+n69A+DT239F48 b4dg== X-Gm-Message-State: AOUpUlFRxMa4r0NcZVjbmVIW7NcJVbM2Wxhser8GrLh2dVPtCjdhcJtd AOP+aLkkgmK76VE9Q93tYXVs1w== X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr81675pfd.252.1533676734090; Tue, 07 Aug 2018 14:18:54 -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 g2-v6sm3688232pfb.79.2018.08.07.14.18.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 14:18:51 -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 7/9] crypto: qat: Remove VLA usage Date: Tue, 7 Aug 2018 14:18:41 -0700 Message-Id: <20180807211843.47586-8-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 new upper bound for the stack buffer. Also adds a sanity check. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook --- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index 1138e41d6805..a28edf7b792f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -153,8 +153,8 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, struct sha512_state sha512; int block_size = crypto_shash_blocksize(ctx->hash_tfm); int digest_size = crypto_shash_digestsize(ctx->hash_tfm); - char ipad[block_size]; - char opad[block_size]; + char ipad[MAX_ALGAPI_BLOCKSIZE]; + char opad[MAX_ALGAPI_BLOCKSIZE]; __be32 *hash_state_out; __be64 *hash512_state_out; int i, offset; @@ -164,6 +164,10 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, shash->tfm = ctx->hash_tfm; shash->flags = 0x0; + if (WARN_ON(block_size > sizeof(ipad) || + sizeof(ipad) != sizeof(opad))) + return -EINVAL; + if (auth_keylen > block_size) { int ret = crypto_shash_digest(shash, auth_key, auth_keylen, ipad); -- 2.17.1