From patchwork Thu Aug 2 22:51:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10554281 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 212A013BF for ; Thu, 2 Aug 2018 22:52:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C7E42C4E0 for ; Thu, 2 Aug 2018 22:52:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F230E2C4E1; Thu, 2 Aug 2018 22:51:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CE1B2C4C2 for ; Thu, 2 Aug 2018 22:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727302AbeHCApO (ORCPT ); Thu, 2 Aug 2018 20:45:14 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42062 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbeHCApO (ORCPT ); Thu, 2 Aug 2018 20:45:14 -0400 Received: by mail-pg1-f195.google.com with SMTP id y4-v6so1886524pgp.9 for ; Thu, 02 Aug 2018 15:51: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:in-reply-to:references; bh=aHfzmuE3dXR4IAoiUCBdTyidzm+NOXbAHoWt0SfC0Yk=; b=YK0sLQ6yx/nNf22z78FvybF7smSHZTnhCRXQxGyslT7EpdDx2alGo3541jQNsGp9vp 8pDZrDntU+idgZMIW2VDvcaO1N0zhTJCjJZIexUkW5A5TeQmfDQqalbe48DGnFU0buQf uEONOy+9a5tJLimhzzgbNSgnmtp8nSNISwRZA= 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:in-reply-to :references; bh=aHfzmuE3dXR4IAoiUCBdTyidzm+NOXbAHoWt0SfC0Yk=; b=YnZvDLvG7S7NxE+T1WcPirFfLakAHxr2FVhXxNV9qpsEK/drSR2/qL0nzXS6SN/dP9 3eOs9a2kUkadhQ7uoEWMzJiAHgN1dQkzq84wCDvhhlEznGTtdalwSCTWqeLbHsHWgRmf swfff/VHhyQ4F8g+sn/20MnaFRIraaAaT2R1QvUeFCyr4pF+bDaUVhZy7OD4S1n8H8pO wk9cIPTkVatBP2y40+S9/degDDaLidUJyex0YC0NrlvN6+il0JdcgJGv0dRBbZQit342 poXaIXj1/n9x5FnNptbw8vkcakJ0Y/94M7wkP8xs3T0RBK352n6FFLgMut9+TqwrGDW5 d7yQ== X-Gm-Message-State: AOUpUlEnMn8hAJtkp1JOwNm8FRWfuRX7AZuFnpeWmjHHbZ3RqC3gYyIp zCS0TZ43W9QT1ZdJy1UOUA4NxQ== X-Google-Smtp-Source: AAOMgpdxUZUIZzGXTUAHJB42T93KR5IqwOqZF7WaiQ/FktZbkan+JYAnOI7iUO0ZrKk468r1i6dY3g== X-Received: by 2002:a63:1902:: with SMTP id z2-v6mr1226160pgl.86.1533250317502; Thu, 02 Aug 2018 15:51:57 -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 y3-v6sm6236173pfi.24.2018.08.02.15.51.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Aug 2018 15:51:56 -0700 (PDT) From: Kees Cook To: Herbert Xu Cc: Kees Cook , Ard Biesheuvel , Giovanni Cabiddu , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Tudor-Dan Ambarus , Andrew Morton , Thomas Gleixner , Geert Uytterhoeven , Arnd Bergmann , Will Deacon , Rasmus Villemoes , David Woodhouse , Matthew Wilcox , "David S. Miller" , linux-crypto@vger.kernel.org, qat-linux@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v7 2/9] crypto: cbc: Remove VLA usage Date: Thu, 2 Aug 2018 15:51:45 -0700 Message-Id: <20180802225152.19194-3-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802225152.19194-1-keescook@chromium.org> References: <20180802225152.19194-1-keescook@chromium.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the quest to remove all stack VLA usage from the kernel[1], this uses the upper bounds on blocksize. Since this is always a cipher blocksize, use the existing cipher max blocksize. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com Signed-off-by: Kees Cook --- include/crypto/cbc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/crypto/cbc.h b/include/crypto/cbc.h index f5b8bfc22e6d..47db0aac2ab9 100644 --- a/include/crypto/cbc.h +++ b/include/crypto/cbc.h @@ -113,7 +113,9 @@ static inline int crypto_cbc_decrypt_inplace( unsigned int bsize = crypto_skcipher_blocksize(tfm); unsigned int nbytes = walk->nbytes; u8 *src = walk->src.virt.addr; - u8 last_iv[bsize]; + u8 last_iv[MAX_CIPHER_BLOCKSIZE]; + + BUG_ON(bsize > sizeof(last_iv)); /* Start of the last block. */ src += nbytes - (nbytes & (bsize - 1)) - bsize;