From patchwork Thu Aug 2 22:51:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10554289 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 6481C13BF for ; Thu, 2 Aug 2018 22:52:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 521102C4C2 for ; Thu, 2 Aug 2018 22:52:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4561F2C4E2; Thu, 2 Aug 2018 22:52:10 +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 C27B32C4E0 for ; Thu, 2 Aug 2018 22:52:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CB0830E684D; Thu, 2 Aug 2018 22:52:08 +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 1D979308BDA6; Thu, 2 Aug 2018 22:52:08 +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 545B04A460; Thu, 2 Aug 2018 22:52:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w72Mq3CK026037 for ; Thu, 2 Aug 2018 18:52:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78C2E7B15E; Thu, 2 Aug 2018 22:52:03 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D58E7BB78 for ; Thu, 2 Aug 2018 22:52:02 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (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 B7DD281F0B for ; Thu, 2 Aug 2018 22:52:00 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id y10-v6so2136901pfn.8 for ; Thu, 02 Aug 2018 15:52:00 -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; bh=Lw1x6/XXm0lKXP9nlcp75yHGkurHRFg6rUCxMz3zWcw=; b=G+87Y9txjkKex5p4nQPg8DFpWzDVHI99Z36eo9cmFvI0MpZiXOXcH41b4/+jayE7RI LuCn8uhmrdRdTO6+rbN3fEZHowc8vSA9577z5TIJElRHr0ABv3OkiSQjUtbRpq/445+G fZaeHlqntKxW6SKEZY9gXAS08sEiQWgKgvK+Y= 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; bh=Lw1x6/XXm0lKXP9nlcp75yHGkurHRFg6rUCxMz3zWcw=; b=APO6okZ+VXmUivxTN6ynQ1YEIYe2ICqzqSZEv7m1J6nJ0CQ6/8S7V13CABs6P7ajV7 Xar1OB8bWA2krZrgiUe+RenUtsUOfMpdUUueGwEZaFTYyA6Tq1Rk4V/BuSPC6+CWW6tw oMtKBA2grisVU4iefBgJr5WUYiHf7ib8RTk4rp9EaY63mk+MrPLu6wWS2eKW7AnPq0F9 tFnriaCMb5vLAGgEZvsJUGbLVwWhflEbETZcC7bX68MPi7mrk4n/dX+Vffx2LqUiXoOJ creccApA3AqtgtUoo+NmCXPsmfYDM8b+h4Oa0xT7XzfFgjNTbALD6BwHEOpv4OQ8v9AB BCDQ== X-Gm-Message-State: AOUpUlHtnGSYkuL58gUexoOMV9iqo/BpNbvcUAhU/Ze01D08fBK2pu/T gqCGSkGidAVpqLAO4M2Mgk0v0Q== X-Google-Smtp-Source: AAOMgpf6POfbDGJKBxUqZiJ0GIdfhMEqOf0U3K0rG+LM2MBDBbsTeGr/XVHjTkHRxwDzM1g3P0YQSQ== X-Received: by 2002:aa7:850b:: with SMTP id v11-v6mr1428270pfn.165.1533250320176; Thu, 02 Aug 2018 15:52:00 -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 s184-v6sm4345186pfb.56.2018.08.02.15.51.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Aug 2018 15:51:56 -0700 (PDT) From: Kees Cook To: Herbert Xu Date: Thu, 2 Aug 2018 15:51:43 -0700 Message-Id: <20180802225152.19194-1-keescook@chromium.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 Aug 2018 22:52:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 Aug 2018 22:52:00 +0000 (UTC) for IP:'209.85.210.194' DOMAIN:'mail-pf1-f194.google.com' HELO:'mail-pf1-f194.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.194 mail-pf1-f194.google.com 209.85.210.194 mail-pf1-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu , linux-kernel@vger.kernel.org, Kees Cook , Mike Snitzer , Ard Biesheuvel , Rasmus Villemoes , Tudor-Dan Ambarus , Will Deacon , Matthew Wilcox , Arnd Bergmann , "David S. Miller" , dm-devel@redhat.com, Geert Uytterhoeven , David Woodhouse , qat-linux@intel.com, Andrew Morton , Thomas Gleixner , Alasdair Kergon , linux-crypto@vger.kernel.org Subject: [dm-devel] [PATCH v7 0/9] crypto: Remove VLA usage X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 02 Aug 2018 22:52:09 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP v7 cover letter: Since the ahash->shash conversions are going via separate trees, I've removed those patches from this series. In the meantime, this contains all the remaining patches for getting rid of almost all VLAs in crypto. I'd _really_ like to get this landed for v4.19. Any chance of that happening? Series cover letter: This is nearly the last of the VLA removals[1], but it's one of the largest because crypto gets used in lots of places. After looking through code, usage, reading the threads Gustavo started, and comparing the use-cases to the other VLA removals that have landed in the kernel, I think this series is likely the best way forward to shut the door on VLAs forever. For background, the crypto stack usage is for callers to do an immediate bit of work that doesn't allocate new memory. This means that other VLA removal techniques (like just using kmalloc) aren't workable, and the next common technique is needed: examination of maximum stack usage and the addition of sanity checks. This series does that, and in several cases, these maximums were already implicit in the code. This series is intended to land via the crypto tree for 4.19, though it touches dm, networking, and a few other things as well, since there are dependent patches (new crypto #defines being used, etc). Thanks! -Kees [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Changelog: v7: - refresh and reorganization without ahash->shash conversions v6: - make xcbc blocksize unconditional - add ahash-to-shash conversion patch series to entirely remove AHASH_REQUEST_ON_STACK from the kernel v5: - limit AHASH_REQUEST_ON_STACK size only to non-async hash wrapping. - sanity-check ahash reqsize only when doing shash wrapping. - remove frame_warn changes in favor of shash conversions and other fixes. - send ahash to shash conversion patches and other fixes separately. v4: - add back *_REQUEST_ON_STACK patches. - programmatically find stack sizes for *_REQUEST_ON_STACK patches. - whitelist some code that trips FRAME_WARN on 32-bit builds. - fix alignment patches. v3: - drop *_REQUEST_ON_STACK patches. The rest of this series is pretty straight-forward, and I'd like to get them tested in -next while we continue to chip away at the *_REQUEST_ON_STACK VLA removal patches separately. "Part 2" will continue with those. v2: - use 512 instead of PAGE_SIZE / 8 to avoid bloat on large-page archs. - swtich xcbc to "16" max universally. - fix typo in bounds check for dm buffer size. - examine actual reqsizes for skcipher and ahash instead of guessing. - improve names and comments for alg maxes Ard Biesheuvel (1): crypto: ccm: Remove VLA usage Kees Cook (8): crypto: xcbc: Remove VLA usage crypto: cbc: Remove VLA usage crypto: hash: Remove VLA usage dm: Remove VLA usage from hashes crypto alg: Introduce generic max blocksize and alignmask crypto: qat: Remove VLA usage crypto: shash: Remove VLA usage in unaligned hashing crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK crypto/ahash.c | 4 +-- crypto/algapi.c | 7 ++++- crypto/algif_hash.c | 2 +- crypto/ccm.c | 9 ++++--- crypto/shash.c | 33 ++++++++++++++---------- crypto/xcbc.c | 8 +++--- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++++-- drivers/md/dm-integrity.c | 23 ++++++++++++----- drivers/md/dm-verity-fec.c | 5 +++- include/crypto/algapi.h | 4 ++- include/crypto/cbc.h | 4 ++- include/crypto/hash.h | 6 ++++- include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 ++- include/linux/compiler-gcc.h | 1 - 15 files changed, 81 insertions(+), 38 deletions(-)