Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp419648imm; Thu, 28 Jun 2018 23:32:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISLBvh7uVtsdH9KvzkwvOMPrpEfy/pCtlaLT5gIpF4MGU0w+uhGqG4i4S54Tz1ofAuMMgJ X-Received: by 2002:a65:4442:: with SMTP id e2-v6mr11501187pgq.53.1530253937399; Thu, 28 Jun 2018 23:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253937; cv=none; d=google.com; s=arc-20160816; b=XSnYghS945u0tSzvddp5mjcOqtEc9jl/sxAYngfCeCsjD+xhcQ7jQEiGrHFDEzn8HL LtdeQteUqLqr05bzNWKasQbh5gRP9YBRu4ENDXSu5xifbaNFFfYHYb+dMQDcNP4euhKT sBXAoEGRDyK1IRE7Ew+pxX/vHOS0fsC1FxL2bCqOEr08rEbXG+1V7DbAHmcqC0+LrGDz 0oE5T9M627NNGLfKjc67KCHSxnKLdvy1QoPPDTMsEUuxJMllWyB6E22em6eraC6w67z3 aqHsbNlBFRKoWVEOGfd2+909PnkHAHtvLIBon6hNsOxLzPZ5vmzKxbKN43TS25olgV0i vokw== 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=WuzfOutcqUk28mRKEIjZPOPNPmcpOyZ0dbmOAsysHUZY+ZOnGdDrT485AMdbH3IwAo hKtktDdAmoa/6h30I4QYEnX0bUkSf02V7wJpnIXWfGG2MicUmY/aTL9WFsMQ+B+mfvit XmIk/ZEnBzBYrkNcauwC13dgmA9CtHgNywt39Gyo0sEwBO4d6SeKnFn5FXGqrJAtkg5K qjmqNsTcC55jD6h/HlgTcRJw3ZLhIhL2pQYkFI4l8vKuMASaYKHrHY22PUJE6C4aIErF b6F3psO4raLZ1ZSjJU2QQ7f21aWqkmFyYLKuP92BGPNEp7tr+qjNm6fhvPBHKxDHqqTs lm3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="CNRl7w/P"; 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 e6-v6si7274934pgq.265.2018.06.28.23.32.03; Thu, 28 Jun 2018 23:32:17 -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="CNRl7w/P"; 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 S936395AbeF2A3A (ORCPT + 99 others); Thu, 28 Jun 2018 20:29:00 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34679 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936379AbeF2A26 (ORCPT ); Thu, 28 Jun 2018 20:28:58 -0400 Received: by mail-pl0-f68.google.com with SMTP id z9-v6so3564371plo.1 for ; Thu, 28 Jun 2018 17:28:58 -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=CNRl7w/Pw6W0IH7G9YGGCFS18ByQgSu4xqGofFYI8RLdjnwWFI6BHUQSTd9KZSAgwO zVcLG7aSLupPorr3vn+V5qA2bM+/3qjc/VPW14pZx+gGiy5fzvrXlxGmbvaecbJUv32P +xo4ZdVOcuXWPKHN/+gPbwKnEOPFs9tOzB6+A= 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=cTGtI4EoS775IoRx8TrcRhyMrpp/3ko3Kol30eTaG+0BSKTEZW4rKOKpLdOmWwtduX leygmlBwxg4iv0J4FXOwvAvakAC+yGKb35YQwfmxInYiRTep7vjrm33ecGAHBs4x4qUN /iYdHPeTrjhPuHYV7FlglHW/OmoJkLoflE/QpwfWFjOlo09K8RavwRHiRE5WeyoR3RvN 4ejApYW6Z3h8z5kr/OpeII9/aMTg8CexZmLhzZ7+0+0+sTd3jjvzvhiIvJXvXJAgkO/i EBGm6KacFNE204FPyeXzMW1cy61loq3UuYY0xQmO5LK51VN676MIm6DbwE86IqIDR8f3 VxhQ== X-Gm-Message-State: APt69E3+mnk1Kh4/3VcF2TGgYUS3A/DEu9wq+pcfsfIER2Z1J7TF9p3Y 4fiyXKzG1wP+DfHS/P1ETe1hDQ== X-Received: by 2002:a17:902:a505:: with SMTP id s5-v6mr12718030plq.66.1530232137721; Thu, 28 Jun 2018 17:28:57 -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 8-v6sm18476001pfk.132.2018.06.28.17.28.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 17:28:53 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , "Gustavo A. R. Silva" , Arnd Bergmann , Eric Biggers , Alasdair Kergon , Giovanni Cabiddu , Lars Persson , Mike Snitzer , Rabin Vincent , Tim Chen , "David S. Miller" , linux-crypto@vger.kernel.org, qat-linux@intel.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 8/9] crypto: qat: Remove VLA usage Date: Thu, 28 Jun 2018 17:28:42 -0700 Message-Id: <20180629002843.31095-9-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629002843.31095-1-keescook@chromium.org> References: <20180629002843.31095-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