Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp419476imm; Thu, 28 Jun 2018 23:32:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLek7np1C2+BhMoJ3ZtWVxLlJc8Iuw1TW8cmJn3A3sB3i5egKFgvIrrdamqV1rD2OIcKS6/ X-Received: by 2002:a63:2dc2:: with SMTP id t185-v6mr11683597pgt.204.1530253923261; Thu, 28 Jun 2018 23:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253923; cv=none; d=google.com; s=arc-20160816; b=N82kI6JWJOGyRky6q0Wkg1hTfSaoJFI7DGoLukqEp4xNZzeHgYX40MPD8WKUOg6GOM nmbQ6WE4yY7Z0eX+lkuaE+TgeZlC/2453su6xGrA1li4QM9juc8inZAifC7xzOT50Fjl 6QAkd7+u5Az6+IVqhtcWvV4jy/z3fMVXrrMA6F9V++QeOkrHuyzrIosCfw5OqZj+fEiZ s4AwNzNPDbociByQfAc75pWqNjkNdmucIeWb5d3Rhhgbr/HQBTjqMpMh8Qb5wqNVv8Uq IN+aDY8LLegTsPNYKZVNmmNBW8litHrQH5KsOoxsLKgNLVta3M8bO6Vqgm2LNHCzAqfn KnFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aHfzmuE3dXR4IAoiUCBdTyidzm+NOXbAHoWt0SfC0Yk=; b=VtAXvHIOCYZpb4V4cmshJdo/qTao2Q3kmxDY93r/hD2tnEA/NVdl+E6nM2578GwYI4 HnvtGDQckMGTm9cHIkRiRdRMH690YO5iCx/RGoIG9yB/ujSXnpPKEMknG3aBa0NbMk6I IONkxNqZ5eqqI7e6TRZG2lJ45QzWIvhD/VWseXlrNu3/e36nBV98DNEDS0GQopYes3k7 t4rKViBmsN/g9MZtUbh4ovcAUvhhiVT5Bog1JLenTor6fhvMdbre1oCP65snjOOnY4vA Wi36+BScCOjvepZe3SA+K3n8rCvRn8P7VYv2pCBLh3tIjfCi03dDO37ytPyYZi+kNFg5 OWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UdR9mAoS; 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 l12-v6si8264511plc.215.2018.06.28.23.31.48; Thu, 28 Jun 2018 23:32:03 -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=UdR9mAoS; 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 S935936AbeF2A2z (ORCPT + 99 others); Thu, 28 Jun 2018 20:28:55 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38839 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932085AbeF2A2w (ORCPT ); Thu, 28 Jun 2018 20:28:52 -0400 Received: by mail-pf0-f193.google.com with SMTP id j17-v6so3356667pfn.5 for ; Thu, 28 Jun 2018 17:28:52 -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=UdR9mAoS/Wp+RLEdrcANBwtdyBkNSaq40jFaJ69AxxHtf+VWplySIlD04o8r2jXeLM tOdmVZW4t1rQEnx7tdVClJYwSX7OP5HgcMrJGvQbQXPCmmlFBaZa6ftkaRPFTpuUpzLj 0JlZZ6uJCFLcVcEDlaMDr8LezDK9fsEEOVyeM= 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=DKkUt2c+j0aMTRCGhObmdbXO4i0sY/ys8vUfMeD+VoM1xvX1LLZ90QQHqzIw4XMOVn fuA1Jj3I0KkJ3HyQMtpHldxhqP8oAY+QQhH7j/K6+hx/ZFqgIY1MpjDwdeI7rofXxefW 8zlc1laWrw/SBOA2/eiwHQhMpjNxkM6X1ub1w6U+1j1o/Y3zQpjMnqfkjfJSfKIhLDxK 8cyTLnmFc8bN/aHdQloiKsiJ6ygY9gM7z09G5uGN9kLguHyHMXp9zfMEbFPXiSsTQj8z K9M6CYSmCztyfl1xrNWUMDHMk3V3AjOnC80gjXdGGyZ6+09gOHZrI7txPqhRNzDn+8TU raDQ== X-Gm-Message-State: APt69E15+Rcq82C3ufiomZce9mJsB2hTyaRfQx6IPv7rMim28BTUkG/m XrUlgHsT4D1nt06Fk3KcsZcQWA== X-Received: by 2002:a65:4acd:: with SMTP id c13-v6mr5843467pgu.436.1530232132260; Thu, 28 Jun 2018 17:28:52 -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 r7-v6sm7956591pfd.154.2018.06.28.17.28.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 17:28:48 -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 v3 2/9] crypto: cbc: Remove VLA usage Date: Thu, 28 Jun 2018 17:28:36 -0700 Message-Id: <20180629002843.31095-3-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629002843.31095-1-keescook@chromium.org> References: <20180629002843.31095-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.1