Message ID | 20180724164936.37477-9-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 7477F90E3 for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6225F2911D for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E6CC29149; Tue, 24 Jul 2018 16:50:19 +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 DE5D32912B for <patchwork-dm-devel@patchwork.kernel.org>; Tue, 24 Jul 2018 16:50:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82B47307C707; Tue, 24 Jul 2018 16:50:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 514ED5D961; Tue, 24 Jul 2018 16:50:16 +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 13F903FCC1; Tue, 24 Jul 2018 16:50:16 +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 w6OGnrM9010860 for <dm-devel@listman.util.phx.redhat.com>; Tue, 24 Jul 2018 12:49:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA380CD0CE; Tue, 24 Jul 2018 16:49:52 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D846CD079 for <dm-devel@redhat.com>; Tue, 24 Jul 2018 16:49:52 +0000 (UTC) Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) (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 59C9E7AE8C for <dm-devel@redhat.com>; Tue, 24 Jul 2018 16:49:51 +0000 (UTC) Received: by mail-pl0-f65.google.com with SMTP id f6-v6so2029034plo.1 for <dm-devel@redhat.com>; Tue, 24 Jul 2018 09:49:51 -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=xi1UiijgPtH3bEbgxLJTLT+H3zXPa7fDlbmxyBVC5QY=; b=dyArO5HPDOmgxu1KqX1PLyjELlLB/4D/84YPYAORv5WvH1EukArfqKSZklwmUMMB7a /TGpsRkqAMjiQVw/mB48Ccn1vguQr0t20yF9CE+lGYxame7S7lxWefDK14kQapdlhLEk 203wUEPeCBMmH4vWUkmIeSP0Tbz3jZdvFjhbE= 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=xi1UiijgPtH3bEbgxLJTLT+H3zXPa7fDlbmxyBVC5QY=; b=NdmNoC4tOw3KL4M8NnAz/0shiaA5A3ipA17Q/Mq/8TVNEg5wcsSPr2S7HnBPrk0OSs AWxGNcQy/VBaOwpf1O8ykDox13R37DUGgN69O9U8tl/UIx8LAFJ/nOdY+bcdjvPnK/mm qF+RdkB+h0VLAbsVBhBbdGyDcw/t2k1RZpYj0gbsErhLaFvK87z7oC+hLKiEoHa1UW+I oQiz8Hrq5AGB75EoCw+/DKmvh+XNnsj5smSEAqw6Y55iirReV2egYntPu8JZM8AGPCDL pI76eTFTnFM1IBWUp7zU+WSdMtHzT4bpYKkiAoCLk7/l2sGiKpgCmO6vCMMPWWsfqETy xM8w== X-Gm-Message-State: AOUpUlGBWmrD5ee3q1rjRiWD5JYN6cpIFZ3oW9m1wC6gQTzj+/xOvoKH oNOkMMdwSlWs3U80F0Av1Yt0Gw== X-Google-Smtp-Source: AAOMgpeVOEL3rwh7h++k7IUoH+FXXTX0DIe/o1QEmZSs2q6LYLTUBCJLP1OSBUBvuU8XEGR4LWmKqA== X-Received: by 2002:a17:902:b112:: with SMTP id q18-v6mr17394185plr.284.1532450990853; Tue, 24 Jul 2018 09:49:50 -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 e2-v6sm13671874pgo.92.2018.07.24.09.49.45 (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:26 -0700 Message-Id: <20180724164936.37477-9-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.25]); Tue, 24 Jul 2018 16:49:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 24 Jul 2018 16:49:51 +0000 (UTC) for IP:'209.85.160.65' DOMAIN:'mail-pl0-f65.google.com' HELO:'mail-pl0-f65.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.160.65 mail-pl0-f65.google.com 209.85.160.65 mail-pl0-f65.google.com <keescook@chromium.org> X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 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 08/18] crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 24 Jul 2018 16:50:18 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
crypto: Remove VLA usage
|
expand
|
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index e42f7063f245..5035482cbe68 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h @@ -130,6 +130,7 @@ static inline struct crypto_skcipher *crypto_spawn_skcipher( static inline void crypto_skcipher_set_reqsize( struct crypto_skcipher *skcipher, unsigned int reqsize) { + BUG_ON(reqsize > SKCIPHER_MAX_REQSIZE); skcipher->reqsize = reqsize; } diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index 2f327f090c3e..c48e194438cf 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h @@ -139,9 +139,11 @@ struct skcipher_alg { struct crypto_alg base; }; +#define SKCIPHER_MAX_REQSIZE 472 + #define SKCIPHER_REQUEST_ON_STACK(name, tfm) \ char __##name##_desc[sizeof(struct skcipher_request) + \ - crypto_skcipher_reqsize(tfm)] CRYPTO_MINALIGN_ATTR; \ + SKCIPHER_MAX_REQSIZE] CRYPTO_MINALIGN_ATTR; \ struct skcipher_request *name = (void *)__##name##_desc /**
In the quest to remove all stack VLA usage from the kernel[1], this caps the skcipher request size similar to other limits and adds a sanity check at registration. Looking at instrumented tcrypt output, the largest is for lrw: crypt: testing lrw(aes) crypto_skcipher_set_reqsize: 8 crypto_skcipher_set_reqsize: 88 crypto_skcipher_set_reqsize: 472 [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook <keescook@chromium.org> --- include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)