Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp7192909imm; Tue, 24 Jul 2018 09:54:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd/HaFxJkQFkTLDkXiHGSi0y85XAnNDVQJ+lfu72C84AzDQiBjK+/cFGbbAxVSoVKL3F9wg X-Received: by 2002:a63:8e41:: with SMTP id k62-v6mr16730596pge.187.1532451273493; Tue, 24 Jul 2018 09:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532451273; cv=none; d=google.com; s=arc-20160816; b=LjwVVvLApYoBfiVdB8w+BfwbkKhyS6eqopw0Owtrzw7lnbi0GIFlTxyFULgm0LlabA bDhS0Yv5NIb0RfE0kdWfW3+tRPEy45CT58VPTVG72fZHU7+GO9jZMT4aTEKWTx6nBAPj 1n/i2922EW1PEuTr10OwsAt4yT8R9mpH3lXu4ttLzNE8fr7ROv/QRW72k24ra6LV2pFZ 0J/qPGgtbYEvbQoY0tjl0+tidcy5IvAyigL7PhRMFVwPl6gYosEWt7gK6VxhNk00bW7C CvkX20c85xsgXjub1fTGz7tHq4qRoBLzKXlubJoB9/llxtLwY7UO/yUXF5pArJ26JSOm 7vYg== 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=xJ9Hr49GRwCmxJaXMkQBXTkJ+ElhT8azFjthNvKkdTF3I2zmGl/lQF958Ns2fho3jF CwGOZPnvIk++q+BCezVc+AVzwP81qN1/4zzYSs2X2Cwq+dGNXTRdT8RGE4t4k/laGwKQ cELuYeqyeRGueX9GIIUpY1T6SJ44YLS3L+t7aMkaEvw9B0lLAQWcJq+/wLa6EsW3rR7x m6lb9Uhv3UZ+QK3ElbnFozt12+Pys8yyk0Dsrzqu8ESUqc5g/wi6UZpoUEkbwu70+5nU XxK4SEfH3/v6XU2B1NCpo87+mCLTwOc8Zubqf4gJBwWUQezISYsonBAKqiTZGrhs9yKM KQxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fbvBHvm0; 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 v34-v6si10722310plg.491.2018.07.24.09.54.18; Tue, 24 Jul 2018 09:54:33 -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=fbvBHvm0; 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 S2388774AbeGXR7b (ORCPT + 99 others); Tue, 24 Jul 2018 13:59:31 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33761 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388549AbeGXR5L (ORCPT ); Tue, 24 Jul 2018 13:57:11 -0400 Received: by mail-pf1-f195.google.com with SMTP id b17-v6so985631pfi.0 for ; Tue, 24 Jul 2018 09:49: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=BYgigRdBSanSiafl9f2cJhj28CjRYh2SZJXlKmlCU5M=; b=fbvBHvm0aVtMNBYkVoeyHxW4qn3bBowhr+yjjR5AVYmmJYLKSk1VUYLbSXZRqNWAN3 sjgO3gTTL1medxbL+lJO5cAoTCtQZXbJbh8kzjkUiP/SMu0qV0avrE+A5M+oV90xVbF+ o0ozqgf8gTqLpEYexFLpKSk1cBWb+tR0nmugo= 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=CQFf7DswGv0q6EWaMHeyhd7pwfcuFCCd8jDwff586sR1b8fndAWpqI/ua3XUOfcY4b J7NuHAnCUhYIOdySPWmNP820H0V1vttW++38ieweNFqFoOfauRPT2vuC9tyDq6hapNUO D15NGOka1Xg93vyybuQ09JDb+plMzq3/dEV5TMPJmiJX9MmMWN30ma0Bi2NvPhwAjXqD U7tTPahVFNEKjfIMRVe114RnQLhOjsvZyZUSLCaELq5YJ93/UdtKzb3XZbeKvxCZLZY+ 0vRtFfL7aOPJ25llvbbODmcvx9riDUmO+1cZ95h0nN5ieq7BijewL++0fg2E5tLnf6Kp iwOw== X-Gm-Message-State: AOUpUlGwEDfOky7jZVXqza3DjzLxm/WvhibTAG8FzN4b2u2oG8ypzqWj xQT8GzR4ACCB7fW+V6KL1PijuA== X-Received: by 2002:a63:62c4:: with SMTP id w187-v6mr16962865pgb.55.1532450989974; Tue, 24 Jul 2018 09:49:49 -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 q140-v6sm16788405pgq.11.2018.07.24.09.49.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:49:47 -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 06/18] crypto: qat: Remove VLA usage Date: Tue, 24 Jul 2018 09:49:24 -0700 Message-Id: <20180724164936.37477-7-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 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