From patchwork Tue Jul 24 16:49:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10542527 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 515151822 for ; Tue, 24 Jul 2018 16:50:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4DA2905B for ; Tue, 24 Jul 2018 16:50:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38BB129127; Tue, 24 Jul 2018 16:50:13 +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 789A2290B8 for ; Tue, 24 Jul 2018 16:50:12 +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 0A5DF30820D8; Tue, 24 Jul 2018 16:50:11 +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 9A4DD3082412; Tue, 24 Jul 2018 16:50: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 A0FCA18037F0; Tue, 24 Jul 2018 16:50:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6OGnpsj010832 for ; Tue, 24 Jul 2018 12:49:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id C106B277BA; Tue, 24 Jul 2018 16:49:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 064F0272D7 for ; Tue, 24 Jul 2018 16:49:49 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (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 EB0CD3082146 for ; Tue, 24 Jul 2018 16:49:47 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id u24-v6so980654pfn.13 for ; Tue, 24 Jul 2018 09:49:47 -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=XDw0a+jCaRK07DPwSkSUufRYjzCRo7QSPtOCTbdYGig=; b=DJygc/ZuxYg2AQ0JUqgfs8uSOmuzC2wxtA9su7QqdjIBMjpPTjtoqTkFsjjOkK13tX DZND+IYwF3ufwEU6d4yCv9al5NkBEhjAgW0Bw1NgqL+cWS6cK4iz3fEyyRcI1i8khmPc 4DJ1U/NXRloXV+JQTjlVXGvHO9J7bQhoArsTE= 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=XDw0a+jCaRK07DPwSkSUufRYjzCRo7QSPtOCTbdYGig=; b=EtmPbvBXXZ5QS8HzM+Yjuufo8iH5ESVlUYXuu9iZO45BTOpVs1o/N8H2PnZo4LokNl tYRc/0IbCjiuylDT8osv3ssOlB51dho4P3Wq/7C2ngdeVAwZ5BIys2UKYg7X/PJV3Nlo alTm/Mjjdx83+rwXoxgsm43No3Wf1G9KAbnuvxnZmifW/+1LknowJTLq12b3OLgo9lVS rDodfMuvTqcQUiXYfeMVH5Pu3iz0JGIZGjuRK5P+NmhLy1ilw2y3ozOpvhKNfPFayBUC TiZQJPuyimupFt5CV1qNzWhcMuiYaaW6jpzVLE2UZGW42mLizZSL0kv7YohBZX6Xhwxa 72xw== X-Gm-Message-State: AOUpUlHZ7TdjjYBBNsDRQFiNRXH770itm/w1rM8LTYu+R0LGP3vUpTXt f5GHg/TNLXjF+mwWlqL/NmcWIA== X-Google-Smtp-Source: AAOMgpejwAxrjuI1z2QcP7sAwD36/xBj0gpdarxw/C4svHwjAhOwWLvU80FDlLknSYQwJO4HAZbEtw== X-Received: by 2002:a63:7703:: with SMTP id s3-v6mr17343122pgc.339.1532450987414; Tue, 24 Jul 2018 09:49:47 -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 d123-v6sm17965601pfa.22.2018.07.24.09.49.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:49:42 -0700 (PDT) From: Kees Cook To: Herbert Xu Date: Tue, 24 Jul 2018 09:49:18 -0700 Message-Id: <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.42]); Tue, 24 Jul 2018 16:49:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 24 Jul 2018 16:49:48 +0000 (UTC) for IP:'209.85.210.195' DOMAIN:'mail-pf1-f195.google.com' HELO:'mail-pf1-f195.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.195 mail-pf1-f195.google.com 209.85.210.195 mail-pf1-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu , Mike Snitzer , "Gustavo A. R. Silva" , linux-wireless@vger.kernel.org, Will Deacon , linux-kernel@vger.kernel.org, David Howells , dm-devel@redhat.com, Jia-Ju Bai , Paul Mackerras , Pavel Machek , "H. Peter Anvin" , linux-afs@lists.infradead.org, Alasdair Kergon , Kees Cook , devel@driverdev.osuosl.org, x86@kernel.org, qat-linux@intel.com, Ingo Molnar , Eric Biggers , Geert Uytterhoeven , drbd-dev@lists.linbit.com, Rabin Vincent , Arnd Bergmann , Tudor-Dan Ambarus , linux-block@vger.kernel.org, Josh Poimboeuf , Thomas Gleixner , Lars Ellenberg , Jens Axboe , Andrew Morton , Greg Kroah-Hartman , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Philipp Reisner , linux-crypto@vger.kernel.org, linux-ppp@vger.kernel.org, Johannes Berg , Tim Chen , netdev@vger.kernel.org, David Woodhouse Subject: [dm-devel] [PATCH v6 00/18] 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.47]); Tue, 24 Jul 2018 16:50:11 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP For newly added CCs on this series: your Ack/Review would be very welcome! Especially for the ahash-to-shash conversion patches. 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 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 Ard Biesheuvel (1): crypto: ccm: Remove VLA usage Kees Cook (17): 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 ppp: mppe: Remove VLA usage x86/power/64: Remove VLA usage dm crypt: Convert essiv from ahash to shash drbd: Convert from ahash to shash wireless/lib80211: Convert from ahash to shash staging: rtl8192u: ieee80211: Convert from ahash to shash staging: rtl8192e: ieee80211: Convert from ahash to shash rxrpc: Reuse SKCIPHER_REQUEST_ON_STACK buffer crypto: Remove AHASH_REQUEST_ON_STACK arch/x86/power/hibernate_64.c | 36 +++++++----- 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/block/drbd/drbd_int.h | 13 +++-- drivers/block/drbd/drbd_main.c | 14 ++--- drivers/block/drbd/drbd_nl.c | 39 ++++--------- drivers/block/drbd/drbd_receiver.c | 35 +++++------ drivers/block/drbd/drbd_worker.c | 56 ++++++++---------- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++- drivers/md/dm-crypt.c | 31 +++++----- drivers/md/dm-integrity.c | 23 ++++++-- drivers/md/dm-verity-fec.c | 5 +- drivers/net/ppp/ppp_mppe.c | 56 +++++++++--------- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 56 +++++++++--------- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 57 +++++++++--------- include/crypto/algapi.h | 4 +- include/crypto/cbc.h | 4 +- include/crypto/hash.h | 11 ++-- include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 +- include/linux/compiler-gcc.h | 1 - net/rxrpc/rxkad.c | 25 ++++---- net/wireless/lib80211_crypt_tkip.c | 58 +++++++++---------- 27 files changed, 313 insertions(+), 287 deletions(-)