From patchwork Tue Aug 7 21:18:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10559199 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 290AF14E2 for ; Tue, 7 Aug 2018 21:19:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1982B2A5F7 for ; Tue, 7 Aug 2018 21:19:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DE4D2A5FB; Tue, 7 Aug 2018 21:19:02 +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 8CD812A5F7 for ; Tue, 7 Aug 2018 21:19:01 +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 61C28C049D66; Tue, 7 Aug 2018 21:19:00 +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 35A0B6374C; Tue, 7 Aug 2018 21:19:00 +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 EE6F74A465; Tue, 7 Aug 2018 21:18:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w77LIrGt011527 for ; Tue, 7 Aug 2018 17:18:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02C4261289; Tue, 7 Aug 2018 21:18:53 +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 ECCE95DD65 for ; Tue, 7 Aug 2018 21:18:50 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.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 C632281F0E for ; Tue, 7 Aug 2018 21:18:48 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id f1-v6so21656pgq.12 for ; Tue, 07 Aug 2018 14:18:48 -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=GJBSyw+dCuiZTzIvf1Q9003/4LB0dv3naSdwyLa2ocs=; b=RhU0h6e98v41YBg0ZTy8pO+7Hiags6PuRwMgeEBw9I/NLCb+XYXweLoCxCsuliDc4A 3pUYLszLvcrk+tYgO+zdpYA/XCCHQeztK476GkPzZkjuGR60QW1HvAxJPTOZf6XaRQVZ WxDWr9BY50M30cdj00cqiZNpSu5xVgPt55vl4= 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=GJBSyw+dCuiZTzIvf1Q9003/4LB0dv3naSdwyLa2ocs=; b=toG62EExrxoEZ2zRfGJZgg/+ILzkXDYQD0AWbsJx1+V981HWOW1Sl3ZxW6LT7ix9Jp OR29ZT4qqCnGBYL87QWBcVHHMYB80ztHua4CSS+2m6zSjrs10fIBx89nqIEHXdNEiRbO UI5UdYVXZi0yDF4KPDQzjfjJ8Pl5gG6n/Vs2+Mb6+m6mCTxXI2Mp/KhHvXGp4A7au3yR Ok8FvmX29tbEkkVASKgdGDNrEBOtvsZu+pWSCT7q7YHbHcioT70xa3BYLAMeUOhc8jsr nGPsBRyAA3Yha2Axx+81XWY5FUEPMijEIEsTwvruTnenVSXHNwLln7tRDvzfilwM+RdS q+Sg== X-Gm-Message-State: AOUpUlGwdNVwSwTlie8++LCLVoFyhjVvXtm+1sPIvD2wYARb/huJARTs deV7T/aTfGaEsvJm5b/QWMTTPA== X-Google-Smtp-Source: AA+uWPzzE9O/ThxdIf3TXndmKi44F3o9HTp6DWG1ku2hgDcUrYWab4GHX8PQ3ep49GXiFs/XqCZTXw== X-Received: by 2002:a62:9f85:: with SMTP id v5-v6mr81135pfk.27.1533676728213; Tue, 07 Aug 2018 14:18:48 -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 x87-v6sm4465849pfa.143.2018.08.07.14.18.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 14:18:46 -0700 (PDT) From: Kees Cook To: Herbert Xu Date: Tue, 7 Aug 2018 14:18:34 -0700 Message-Id: <20180807211843.47586-1-keescook@chromium.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 07 Aug 2018 21:18:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 07 Aug 2018 21:18:48 +0000 (UTC) for IP:'209.85.215.194' DOMAIN:'mail-pg1-f194.google.com' HELO:'mail-pg1-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.215.194 mail-pg1-f194.google.com 209.85.215.194 mail-pg1-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu , Matthew Wilcox , linux-kernel@vger.kernel.org, Kees Cook , Mike Snitzer , Ard Biesheuvel , Rasmus Villemoes , Eric Biggers , Will Deacon , qat-linux@intel.com, Arnd Bergmann , "David S. Miller" , "Gustavo A. R. Silva" , dm-devel@redhat.com, Geert Uytterhoeven , David Woodhouse , Tudor-Dan Ambarus , Andrew Morton , Thomas Gleixner , Alasdair Kergon , linux-crypto@vger.kernel.org Subject: [dm-devel] [PATCH v8 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.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.31]); Tue, 07 Aug 2018 21:19:00 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP v8 cover letter: I continue to hope this can land in v4.19, but I realize that's unlikely. It would be nice, though, if some of the "trivial" patches could get taken (e.g. cbc, xcbc, ccm VLA removals) so I don't have to keep repeating them. *fingers crossed* 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: v8: - remove "impossible condition" BUG-check in cbc. v7: - refresh and reorganize without ahash->shash conversions - merge hash maximums for both shash and ahash 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 | 2 +- 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, 79 insertions(+), 38 deletions(-)