Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp82330imm; Tue, 7 Aug 2018 14:21:54 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzNeUovXtUzIXSK+hjAY2FDGZThOGe4rn9eFHYhr5Yzvk7S8spIw6NoCqtR0A6Ju/Iyt0rQ X-Received: by 2002:a63:1f4d:: with SMTP id q13-v6mr67430pgm.241.1533676914131; Tue, 07 Aug 2018 14:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533676914; cv=none; d=google.com; s=arc-20160816; b=Y7VJzKll1WK9DHc7LJjOBF1TyAhKmtwfnMATpfP4tFNgqWrqHyp74wgwQkBKiq2NlO E8sYEdXhksp8s2WQp/KpUsNJlLHb4cFsPqWXlYO2f09tP7OEUK//Ia6GzBKdVs1yY/xt TDlfIF4wrrFWtTjVWuOCMyiHpWV8VZCRTh25ikJIfSXcsbBPsaQ42eYgyF4bzEPtaGGO cWdqCdooyfYuzgi/IbWEI+TmZQ1EuNnhTjD9CwEVtEfKoHHMkMxRFyinFjf6VEuJ/B9a dVRfrgfaQn/MUDsw6ONRo4H8zCY/yMOQfJ59wB79fJ4gVFI+ODR9acKQtFUa6TDcVHys z5TQ== 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=GJBSyw+dCuiZTzIvf1Q9003/4LB0dv3naSdwyLa2ocs=; b=h4vwUMrngkViwEjEigSlpkv0jbImF9Pk294Y2vk7N4xAvYphRrFWPZYou8ygf1jzHU PZV9wnT2ZSB2Y6gOGaUuDZ3CEkCQJ88Rd2sDAzaGiGOrCAXBWvCjqowKge5x1hbrwg8a S+pQfQRFAquemQh6WKtj4EdGAnFjzBdyrh9m3GUOmothQrePlFONTY7CPFPBPnP/x1iq ztxOXf3iS9XQwxzpSr4Kgz+BRJrgEn23QrCK6ojKRGMDyybGWs0blLKTV5mw9TbiLT9J ADBpHlk7U9nOhdE+EPhVGEa3j8XsLHBmWDuPsl4I8ey4/B53hlNtu0ZbpmYTODRWC2bT kG1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RhU0h6e9; 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=REJECT sp=REJECT 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 n24-v6si2458944pgb.665.2018.08.07.14.21.37; Tue, 07 Aug 2018 14:21:54 -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=RhU0h6e9; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbeHGXfJ (ORCPT + 99 others); Tue, 7 Aug 2018 19:35:09 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43180 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbeHGXfH (ORCPT ); Tue, 7 Aug 2018 19:35:07 -0400 Received: by mail-pg1-f195.google.com with SMTP id a14-v6so26546pgv.10 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=IYes4mK2X5vBZlWa6AyLDvhHMO/QZIe1Cld7JFSTTjr6RhsYblqEBqIB8Xz7BphlZ/ vghIZ5ew0XNXIHIx8weZXIRZRq7OWjBnfkKBA2l6NDfchjuQzNl8MvP/sYzvvr8nRoER /8DrikanW5CFsC5BaXg1pSflMGR4qIOhHOAFR8/LfGFu1od+5fVaeyK7gB+cxeYtRWUl JA16IJssQmeKJrbySLc6XOx8oNE0ZCHUCDdVg42STVhuocOyCPvoWGwJBJHHYBGcYYqk +ztFnwuifavfXeTpuMvPCHATXDEs7R67vwqKRbyDUZGE0FfiBVOFg+9+GyCUAjto4sr6 OMEQ== X-Gm-Message-State: AOUpUlG49qReCkpeOKfbuYzVbtK/9jLK09deN+N30+MA+bjjlZsHo9YM G/XYrKK7ASF7kDh0zNl3SiGWByqKTRE= 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 Cc: Kees Cook , Eric Biggers , Ard Biesheuvel , Giovanni Cabiddu , Alasdair Kergon , Mike Snitzer , Tudor-Dan Ambarus , Andrew Morton , Thomas Gleixner , Geert Uytterhoeven , Arnd Bergmann , Will Deacon , Rasmus Villemoes , David Woodhouse , Matthew Wilcox , "David S. Miller" , "Gustavo A. R. Silva" , linux-crypto@vger.kernel.org, dm-devel@redhat.com, qat-linux@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v8 0/9] crypto: Remove VLA usage Date: Tue, 7 Aug 2018 14:18:34 -0700 Message-Id: <20180807211843.47586-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 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(-) -- 2.17.1