Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp7197502imm; Tue, 24 Jul 2018 09:59:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeC8U/z3rhZeqWjYgovJWxBk6U/rviXf7X5u+ST/JMXMlla/DMS6BdPUymJN51ZDuckhHlD X-Received: by 2002:a62:fd06:: with SMTP id p6-v6mr18129196pfh.167.1532451573506; Tue, 24 Jul 2018 09:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532451573; cv=none; d=google.com; s=arc-20160816; b=UadBnVq1X/OW+KEflQgSf5kInvl5Go8KD4Yu9cuhdlHuxjSHpH/HS7UQ9LoOFobG6r x6tQ0mdagu5VjU2YRtV0KkjZqxIs15A3TCVsh0TxHtRJHs6weAlXRPudJmErQx/O1PKL 7sJ3c099zysORVjZDdEQ2mLkER81n9m9jvbJVQBAdu/OzV3prznjx37AAUibNWz1RnLn Buq8a9wfwl+g/WFCCRydAt+ikKrdvhOsR6vJ6Ha2UIayDeFn5ITzp3a/UzjYkdTvRCoY mXA4mE80oMBGe9z2UAk3CLV9qpf1ja89jWwhuoZeEoToIbs5fF5rEcTDR90tzII5oTv+ X5Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=VoVAj1ZkTXmNlv9r3osCFCaIs3/6JtsSKqlipDGMjBs=; b=ONIh4K65PKEbJ0Gp7fxnd1G5ERz3vX0XOKeFhH6zCFd9CFw2vDUruISmmkTUcqmpwZ +wTSgsK3GOMJZ6/rZgFdOZsCFxuxfehdXh5ouQlQd4Yf5KqFgqfh7BxTbreyD2kA6j3H A8zSBrK4IGLfirbHUE4m0wMbT39lvuIDmtueBT9/2rh3FkqyITBsEtKcHH0CaRMH9Icy PKvp9IyCKBnsebdxMrWPab/MKyizKSQxcI34N7JuGTkhdHHLLgnC8SBUrgGToffhDcHK yzq1fpI6yXjLRbmj36HzFmluK1Jtaeef0cqbsnh6XIe0iuT5Pd5jWKn34h3ZDkI8hf+N 8IeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXoGCuRI; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186-v6si10792709pgc.453.2018.07.24.09.59.18; Tue, 24 Jul 2018 09:59:33 -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=@linaro.org header.s=google header.b=KXoGCuRI; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388530AbeGXSFI (ORCPT + 99 others); Tue, 24 Jul 2018 14:05:08 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:35915 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388393AbeGXSFI (ORCPT ); Tue, 24 Jul 2018 14:05:08 -0400 Received: by mail-io0-f193.google.com with SMTP id r15-v6so3996008ioa.3 for ; Tue, 24 Jul 2018 09:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VoVAj1ZkTXmNlv9r3osCFCaIs3/6JtsSKqlipDGMjBs=; b=KXoGCuRICJNUfLKpDRIixnGzlMaOvHfwa24W5yOHQSUZaJJlYGsKeCLQ0u/+niWjZr 44wFUYaDodmrTb++1C+5RLrbmeas62cmoDINxfeYk781Ye7qHTV92zipcF8slNaTfAdP uKdlUUZpW+kf0LRgtOgwOCDySVx32o7OS4gfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VoVAj1ZkTXmNlv9r3osCFCaIs3/6JtsSKqlipDGMjBs=; b=WV+RMn4Ki1Z1DExcPFW+UF14wb2IW6BuCVyKdRNSmRJjDpttPfu2UWBq2hmVCPPZBg DG+AVcWwa5JXtkHYj6SiblmwDFYdn31WtrXms0eH8nzNuE92SpJ1mCN9MYBhRjjJRXQh pP6FRE3SACnU5syObPI8yzBlk9lGOQmvjOumwMPq9fhsnIEgIxwqzaXKZvSFhe6q20jd qE353OvEtd6+cqyf1b1gwSMqo7davCumRGgOw6+hIbm3lJjMn1hxF1qMLeI5LwZC7vhb q820d7CzX13RTigKPDSoe9jZXACW5cxNDKdYM+OzgdvWuwjE0GWMRpFAjtVU9OprpViq CPEg== X-Gm-Message-State: AOUpUlF1BIQcFMX+3N07p/H9kvwPy6ttWttiQCl9AfcAnxjXjTC/lgSL 7O7j9RJDU5V5Gka/6SjJES+wrq+RCpmc7u2erYEURA== X-Received: by 2002:a6b:be83:: with SMTP id o125-v6mr13941027iof.173.1532451464793; Tue, 24 Jul 2018 09:57:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:57:44 -0700 (PDT) In-Reply-To: <20180724164936.37477-18-keescook@chromium.org> References: <20180724164936.37477-1-keescook@chromium.org> <20180724164936.37477-18-keescook@chromium.org> From: Ard Biesheuvel Date: Tue, 24 Jul 2018 18:57:44 +0200 Message-ID: Subject: Re: [PATCH v6 17/18] crypto: ccm: Remove VLA usage To: Kees Cook Cc: Herbert Xu , Arnd Bergmann , Eric Biggers , "Gustavo A. R. Silva" , Alasdair Kergon , Rabin Vincent , Tim Chen , "Rafael J. Wysocki" , Pavel Machek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "the arch/x86 maintainers" , Philipp Reisner , Lars Ellenberg , Jens Axboe , Giovanni Cabiddu , Mike Snitzer , Paul Mackerras , Greg Kroah-Hartman , David Howells , Johannes Berg , Tudor-Dan Ambarus , Jia-Ju Bai , Andrew Morton , Geert Uytterhoeven , Josh Poimboeuf , David Woodhouse , Will Deacon , device-mapper development , linux-pm , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, qat-linux@intel.com, linux-ppp@vger.kernel.org, "" , "open list:ANDROID DRIVERS" , linux-afs@lists.infradead.org, "" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24 July 2018 at 18:49, Kees Cook wrote: > From: Ard Biesheuvel > > In the quest to remove all stack VLA usage from the kernel[1], this > drops AHASH_REQUEST_ON_STACK by preallocated the ahash request area > with the skcipher area (which are not used at the same time). > -EGRAMMAR > [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com > > Signed-off-by: Ard Biesheuvel > Signed-off-by: Kees Cook > --- > crypto/ccm.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/crypto/ccm.c b/crypto/ccm.c > index 0a083342ec8c..b242fd0d3262 100644 > --- a/crypto/ccm.c > +++ b/crypto/ccm.c > @@ -50,7 +50,10 @@ struct crypto_ccm_req_priv_ctx { > u32 flags; > struct scatterlist src[3]; > struct scatterlist dst[3]; > - struct skcipher_request skreq; > + union { > + struct ahash_request ahreq; > + struct skcipher_request skreq; > + }; > }; > > struct cbcmac_tfm_ctx { > @@ -181,7 +184,7 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, > struct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req); > struct crypto_aead *aead = crypto_aead_reqtfm(req); > struct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead); > - AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); > + struct ahash_request *ahreq = &pctx->ahreq; > unsigned int assoclen = req->assoclen; > struct scatterlist sg[3]; > u8 *odata = pctx->odata; > @@ -427,7 +430,7 @@ static int crypto_ccm_init_tfm(struct crypto_aead *tfm) > crypto_aead_set_reqsize( > tfm, > align + sizeof(struct crypto_ccm_req_priv_ctx) + > - crypto_skcipher_reqsize(ctr)); > + max(crypto_ahash_reqsize(mac), crypto_skcipher_reqsize(ctr))); > > return 0; > > -- > 2.17.1 >