Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3078803imm; Mon, 16 Jul 2018 21:24:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf9KPVvWFWlpow+PS0tr/SBJjAkPMIhenxuARrqHOBQpkFkdqIjeIbNkA8neZThceD3o2Fj X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr49748pfk.10.1531801490753; Mon, 16 Jul 2018 21:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531801490; cv=none; d=google.com; s=arc-20160816; b=pQrbqzoEBjxzKovO/aGtPR+V45X04B4Z0FDeBYvE0zDP7FpNkoD+H/8ltyDvgVO+zv 8FIt1cTE0k2KfoUHDPMYbklO5xFX/8lHjJgeiIYdwqC95cFp3cWtb2ZGOqbwNwr2RMLI ocXY739hfDd8S+PzqiwHoqP1/Six6fGoY6375qiidE8IgKKUXxSyiavlCUpxaF1BsAfE Ix0n6TY3m9rK7tBkhL6Bd287213LiO3Qp6SIjH7brUdd8wr/D6UCkfzNK4F6rHq/NBQG GpQngoEkReAHFVDt6FYBkAAOWxvO3iYI+CS7PcgWf058MjniuSAfKQSG2RN8guGHKv2J Yk2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Z5Bt8w1FWlfFrHcBVrOM+ClUStFhbI+Y1ZodLgd//8E=; b=rQ1iOXYIgFtsH/s7wFTa2+HVbiASbTKMWfG6uXBiXRsuL0eqg3iiO1TdDrCX8w6ngJ xKwuepwlrriQ90VrPXN+fa7QSqQglmN+TS+DKATUGS9s2dHTgxjVjVzX9U/s/KbK3Y6a RIqAnpeH+l+ekbieN/mkmwuXLu7w6WqQpLdFtEvdYDoZzCcvNei0ze6xdtGTTPeUgA2E +EsSUsRd/BiahxMF3Od0YzNokBPbTsW+wyr90VHEHnqead2zyuKRUQBxJ7mE/jkZqdYz IOGbwkrDs0OBB4i2iIzErm3+BV42B8irLG0xsjv/VS3dbLw/D12Jc8qai50QRnHD1XNJ QgaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KFRqd4aI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si12882635pls.53.2018.07.16.21.24.35; Mon, 16 Jul 2018 21:24:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KFRqd4aI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729656AbeGQEwe (ORCPT + 99 others); Tue, 17 Jul 2018 00:52:34 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40714 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729614AbeGQEwd (ORCPT ); Tue, 17 Jul 2018 00:52:33 -0400 Received: by mail-pg1-f194.google.com with SMTP id x5-v6so8396462pgp.7 for ; Mon, 16 Jul 2018 21:21:58 -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=Z5Bt8w1FWlfFrHcBVrOM+ClUStFhbI+Y1ZodLgd//8E=; b=KFRqd4aIZqhgVsnmop43d3o5Qm5rmBHxz5CPgQzhxmwkxA9iVhCH+3iaYEw7WIenA6 3uCgKRDA8cJHJsA+O1ZLORt/TZ8esB3H+6/mE0YmrUuMh2esD1HUfaJS6NPfKHKK4tfs J4CKUOdira1hr99ozia9YZ74fFp5sgWZ6Un+g= 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=Z5Bt8w1FWlfFrHcBVrOM+ClUStFhbI+Y1ZodLgd//8E=; b=LWzpG3Gerk+Wy4xQm18BH0Dy+PXzohJOl44kRdmhNDPZGoveUud7Ez3XjKkI22UNez bIVB9e+ShVv3mhH32Q4EKRqtY/dZXG73jYwm32sYE9irLtezcGZXCtr9+PsPwGY1vasU 7l/qLFKQbSVN3ikjteZ7FnKj5wEv7hJYOgyKDfIMhZmA2FIuSjdB7l90L2e+3XR4oNbW IX33CukWGRYT9pZ5RUKE2uz64xi17BMp1AGmx6YCTCJUCScrzNT66qmN1mBbnRzd1A9Y YQ+b0vR+ZeKcNv69SEMK0cuhiJucE8wfekeqR+dR5qvY4bD/OLTekfp9rmUs1akaYEU6 Tyrg== X-Gm-Message-State: AOUpUlHeMNgLyLE2qHen7uOW44yoFp3CVl73oxqXPlcI50YZ/0BmnZY/ lgc7x0r0zzxZxPOYRxRgBIDBuw== X-Received: by 2002:a63:9e0a:: with SMTP id s10-v6mr18870pgd.326.1531801318201; Mon, 16 Jul 2018 21:21:58 -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 h10-v6sm43493964pfj.78.2018.07.16.21.21.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 21:21:53 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , Arnd Bergmann , Eric Biggers , "Gustavo A. R. Silva" , Alasdair Kergon , Giovanni Cabiddu , Lars Persson , Mike Snitzer , Rabin Vincent , Tim Chen , linux-crypto@vger.kernel.org, qat-linux@intel.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 00/11] crypto: Remove VLA usage Date: Mon, 16 Jul 2018 21:21:39 -0700 Message-Id: <20180717042150.37761-1-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. As 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 and a few other things as well, since there are dependent patches (new crypto #defines being used, kbuild, etc). Thanks! -Kees [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Kees Cook (11): crypto: xcbc: Remove VLA usage crypto: cbc: Remove VLA usage crypto: shash: Remove VLA usage dm integrity: Remove VLA usage crypto: ahash: Remove VLA usage dm verity fec: Remove VLA usage crypto alg: Introduce generic max blocksize and alignmask crypto: qat: Remove VLA usage crypto: shash: Remove VLA usage in unaligned hashing crypto: ahash: Remove VLA usage for AHASH_REQUEST_ON_STACK crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK crypto/ahash.c | 4 +-- crypto/algapi.c | 7 +++- crypto/algif_hash.c | 2 +- crypto/shash.c | 42 +++++++++++++++--------- crypto/xcbc.c | 9 +++-- 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 | 19 +++++++++-- include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 ++- include/linux/compiler-gcc.h | 1 - 14 files changed, 97 insertions(+), 36 deletions(-) -- 2.17.1