From patchwork Tue Jul 24 16:49:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10542633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 886E91822 for ; Tue, 24 Jul 2018 16:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7658B291F2 for ; Tue, 24 Jul 2018 16:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7332A291F7; Tue, 24 Jul 2018 16:52:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1834A2919C for ; Tue, 24 Jul 2018 16:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388488AbeGXR7h (ORCPT ); Tue, 24 Jul 2018 13:59:37 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39460 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388547AbeGXR5K (ORCPT ); Tue, 24 Jul 2018 13:57:10 -0400 Received: by mail-pf1-f193.google.com with SMTP id j8-v6so982156pff.6 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=uRd/LUKyk2kniPxdw0ei0FwVnkOKtY1aUv1AiqzzYaeQm92jUZ1CwzWVkotQK6h4uS EjxqAptKzZXsJ0rG+g+SxwNa+3RmDRcT82bFUNHVnhHoo00y8DfLi5dTVDMoWt+Sr8Tz LNyIJ6Va3iQrkPp3UMH6gvbnl0pll7yqVDb7ykxllPvYVxLyGfjbxrrUwqm/9l16I5h3 lzaKUTxEJSX4on5Y3ojMNoStgO/wtJabUWsJPoRGatFGfMamP1JTT2EDdbRBAFUppo1k 9jE64UJfunf/5oakA4by7bnoCjki0+UUtcshQHfyNdMagSQ+ye4On+msF2RTVtHH1rGf DRWg== X-Gm-Message-State: AOUpUlE0HfuK/d5GDfXmd18emY5QcOgkwYC90uSXucdeY9u1itvRksa9 7Fs1J83DzpJvwQ9eXiyZSkSuHQ== X-Google-Smtp-Source: AAOMgpejt/8eaP/vX2Mv3zbSbY3cKd9odRDYEzzOSvdKQxeog2q1a3bDuwwt7lah0vUOGzlRRfPMAg== 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);