Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4350286imm; Mon, 25 Jun 2018 14:15:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3rbaznKV/aEICPKg2touj+49k85SCUcm0j3EpKgwBmKNlC3xXQVEAZo94iPOYjZ9Uwvb5 X-Received: by 2002:a63:6d8b:: with SMTP id i133-v6mr6670022pgc.215.1529961299991; Mon, 25 Jun 2018 14:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529961299; cv=none; d=google.com; s=arc-20160816; b=rCfyY9P7C6fgNpAUqzZoQDAI9g2/0PnSQqeukFC8HzR9B7zMMhkRyEqxTYiRoZrIw3 GGdryDdvzpKc7sK8NrTzyb9t09e31tUVy58vxz5w4oc1p9PzqF12NeNGyawfUhIKOfPJ UPZn+cwVbsFHO4ZFvyiz2x2KMethv7c/NaEDLQ7rw1y59SFNzbybpPHfuSwCQluD4tTG tyUej0Lh954i2gP180fCMKzjsmfh5OQm+AWVOLvpCD7Nt8HLLmmM51uVpN2DtNQQlGFv hCI5O7RWTbb1L270JKSXTmICZKkgr7NHUP5TmLNd6VMjem+jLaREuVp3/PMyxOak9d/D NaUA== 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=kwaz9ZiWPqqFFPa8Ruto1w30icdNQNK+d0gZGLO5eRI=; b=T/GBpQ+L8OCjsf9ZKCVoR6eRHTFOIL7js+PBBoOnL0F+V21SfBYNDA9+x2AF47hZEf krk/E7GtUlSQK4c21HxvnCg9N5WHc1DBh4YmyZZtOVosl9iX/OKP4qzcVO2EM7ttewMs 6z9Ff88hBuBl/nN+Rase+8nYUPK0rZcrRuRVH9g5Rd4qUnh9gfwysOj6hn+mjKHEmodp Wj4Z4XZdRJTpo/KJ7a7qAkxbGh5PHOGxAxPF3+HJzNfaiRtEhIgvIefNmXHUHQSuAWJm gaaa+NJrZ3viWu2XZW8MZQO8v0sRYDzjOAaRu7s9GRW9zySloJK/kMwVQNA/ptv6HEPX 4rZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IoK3kKqO; 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 k185-v6si12418104pgc.468.2018.06.25.14.14.45; Mon, 25 Jun 2018 14:14:59 -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=IoK3kKqO; 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 S1755779AbeFYVNS (ORCPT + 99 others); Mon, 25 Jun 2018 17:13:18 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:37508 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752086AbeFYVKi (ORCPT ); Mon, 25 Jun 2018 17:10:38 -0400 Received: by mail-pf0-f194.google.com with SMTP id y5-v6so7030861pfn.4 for ; Mon, 25 Jun 2018 14:10:38 -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=kwaz9ZiWPqqFFPa8Ruto1w30icdNQNK+d0gZGLO5eRI=; b=IoK3kKqOEFknoDX0abloQQbmstnZYB55RYYQf9KQP7dXcLTBKgAT1I4w2wa6fpfkCL +qVy/8dQaZ/atX/z1SJ4rUFZ6fGPYkTOK+hKObzyZNbTgPjb3SrfnM3/Xqxc+YvxHNAA xYHhXXc3jcKqpcvbzC3pmAvximRd9J/mb+cPI= 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=kwaz9ZiWPqqFFPa8Ruto1w30icdNQNK+d0gZGLO5eRI=; b=FuBNLXB+6a7smWfKy4Tg+z6zI0dBeKnqvBFdHAxvoOVp5t87KInxSSLodgXb3suHZb yMH8zsTAivePiBho7uUsG02hIMSY02Eim/84WPz1GoueV1OlRZLomu9T3ChNp+RqJTxX nHwQxD+GT/L6hpga/xm5Zwx0cOHTrk7GHqubre3w3IshZziwLjcb15JMyb31yu51TnVS AD5g9mQQmIQiZ9fDdIKcfOIqs4+5nrEmbOOWqbeTfzyt3L53uvnIuO3PWe/e+KsUcjI9 8hSUXOwOSHOtzDM/Z3kM9LT8mrya25F1svhwsKQ3Dm/XGPsRzS3T36jiSbwdtrE5LDap yCig== X-Gm-Message-State: APt69E0g3M6YXC3PNW+zh4NMgcvbyGXFNczn/FLDUfeDA2LPYNPy5pjp Yn5TKxZFJJ/B7AAJgODGfIrfFQ== X-Received: by 2002:a63:9246:: with SMTP id s6-v6mr11125983pgn.35.1529961038495; Mon, 25 Jun 2018 14:10:38 -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 h8-v6sm19760277pgq.35.2018.06.25.14.10.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 14:10:35 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , "Gustavo A. R. Silva" , Arnd Bergmann , Eric Biggers , Alasdair Kergon , Giovanni Cabiddu , Lars Persson , Mike Snitzer , Rabin Vincent , Tim Chen , "David S. Miller" , linux-crypto@vger.kernel.org, qat-linux@intel.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 00/11] crypto: Remove VLA usage Date: Mon, 25 Jun 2018 14:10:15 -0700 Message-Id: <20180625211026.15819-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 Hi, 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, though it touches dm as well, since there are dependent patches (new crypto #defines being used). 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 | 25 +++++++++++------------- 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 | 12 ++++++++++-- include/crypto/internal/hash.h | 1 + include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 +++- include/linux/compiler-gcc.h | 1 - 15 files changed, 75 insertions(+), 35 deletions(-) -- 2.17.1