Message ID | 20180724164936.37477-7-keescook@chromium.org (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Mike Snitzer |
Headers | show
Return-Path: <dm-devel-bounces@redhat.com> 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 6B8861822 for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57E5C29063 for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 545C229073; Tue, 24 Jul 2018 16:50:17 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71D0D29154 for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD5E87E436; Tue, 24 Jul 2018 16:50:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EEFE5C880; Tue, 24 Jul 2018 16:50:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4C43E18037F1; Tue, 24 Jul 2018 16:50:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6OGnq7u010852 for <dm-devel@listman.util.phx.redhat.com>; Tue, 24 Jul 2018 12:49:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D45A7CC6C6; Tue, 24 Jul 2018 16:49:52 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B59E4CB190 for <dm-devel@redhat.com>; Tue, 24 Jul 2018 16:49:51 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 752D030820EF for <dm-devel@redhat.com>; Tue, 24 Jul 2018 16:49:50 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id d14-v6so986622pfo.3 for <dm-devel@redhat.com>; 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=nJp/NqMbPkGz/j7r4c0fWb9W1qC23SAmdigeBJaUkrzLd3KkMkYvENEECMrqyRGNOO BcOpl3AfvaOUJhcrpXoWbEqjOKwddYQxjOFk/CHmDs9agKJtkDn+q858LB4SdaGB6fre FASsVlQdEzPqDL7dWITuBkFbyDoQS20mBWRgpI7wmfbuZBZIoJiYcuq7jkAyYmBwKygN P5J/i1WHIl871fKyT3qakrkVEULwOX9CLNksRn+26xIifUgW4kbIG5FmkAx/lOwtvGKd Je4Yemgx+UJwrOOrjOy2vNxKcob4axOxcmkOwTafYoJVMRGgbWvHIxeKlb1guQu/4u29 qYfw== X-Gm-Message-State: AOUpUlE70lLMCmwwA+KB7qtQd3hZ24j9et+CH2GHoRpqUime8mGUk0D5 Lvv+/UVaDziBRxSs8b0Gm9tG/w== 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 <keescook@chromium.org> To: Herbert Xu <herbert@gondor.apana.org.au> Date: Tue, 24 Jul 2018 09:49:24 -0700 Message-Id: <20180724164936.37477-7-keescook@chromium.org> In-Reply-To: <20180724164936.37477-1-keescook@chromium.org> References: <20180724164936.37477-1-keescook@chromium.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 24 Jul 2018 16:49:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 24 Jul 2018 16:49:50 +0000 (UTC) for IP:'209.85.210.193' DOMAIN:'mail-pf1-f193.google.com' HELO:'mail-pf1-f193.google.com' FROM:'keescook@chromium.org' RCPT:'' X-RedHat-Spam-Score: -0.131 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.210.193 mail-pf1-f193.google.com 209.85.210.193 mail-pf1-f193.google.com <keescook@chromium.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu <giovanni.cabiddu@intel.com>, Mike Snitzer <snitzer@redhat.com>, "Gustavo A. R. Silva" <gustavo@embeddedor.com>, linux-wireless@vger.kernel.org, Will Deacon <will.deacon@arm.com>, linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>, dm-devel@redhat.com, Jia-Ju Bai <baijiaju1990@gmail.com>, Paul Mackerras <paulus@samba.org>, Pavel Machek <pavel@ucw.cz>, "H. Peter Anvin" <hpa@zytor.com>, linux-afs@lists.infradead.org, Alasdair Kergon <agk@redhat.com>, Kees Cook <keescook@chromium.org>, devel@driverdev.osuosl.org, x86@kernel.org, qat-linux@intel.com, Ingo Molnar <mingo@redhat.com>, Eric Biggers <ebiggers@google.com>, Geert Uytterhoeven <geert@linux-m68k.org>, drbd-dev@lists.linbit.com, Rabin Vincent <rabinv@axis.com>, Arnd Bergmann <arnd@arndb.de>, Tudor-Dan Ambarus <tudor.ambarus@microchip.com>, linux-block@vger.kernel.org, Josh Poimboeuf <jpoimboe@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, Lars Ellenberg <lars.ellenberg@linbit.com>, Jens Axboe <axboe@kernel.dk>, Andrew Morton <akpm@linux-foundation.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-pm@vger.kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>, Philipp Reisner <philipp.reisner@linbit.com>, linux-crypto@vger.kernel.org, linux-ppp@vger.kernel.org, Johannes Berg <johannes@sipsolutions.net>, Tim Chen <tim.c.chen@linux.intel.com>, netdev@vger.kernel.org, David Woodhouse <dwmw@amazon.co.uk> Subject: [dm-devel] [PATCH v6 06/18] crypto: qat: Remove VLA usage X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development <dm-devel.redhat.com> List-Unsubscribe: <https://www.redhat.com/mailman/options/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=unsubscribe> List-Archive: <https://www.redhat.com/archives/dm-devel> List-Post: <mailto:dm-devel@redhat.com> List-Help: <mailto:dm-devel-request@redhat.com?subject=help> List-Subscribe: <https://www.redhat.com/mailman/listinfo/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 24 Jul 2018 16:50:14 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
crypto: Remove VLA usage
|
expand
|
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);
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 <keescook@chromium.org> --- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)