Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1198780imm; Wed, 20 Jun 2018 13:24:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMhqJafwhdAJao7h/ErpUJ+3y06Qusqi/xmBRQn+fuH4ODXCxdZIK2/M504X+v6MMy8EmI X-Received: by 2002:a63:8848:: with SMTP id l69-v6mr20429499pgd.149.1529526260032; Wed, 20 Jun 2018 13:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529526260; cv=none; d=google.com; s=arc-20160816; b=DzEylQBSppnSeFoAkZejpdDre6VKDkKGDVNydyma1zoxO5gdYNZ+XiCo7/UBNYkaKK xcvYLWi7FkGjjhhYpdTNKd5Di2lPK9ro/qz5YXo/H8ORegK1Jh4dBOmfN3hyklMJvelJ s8xfDa2gH8iWr/t4anfazhxk7EiF+KnI1g1htBjvLLNvjXXCrFLdQ7Otd/csSUNAjp0W Wb0JUu4hd3jfvlddKeCdyK0Jv0FD1NfGKeJm5br3W6cgyq7hYaveXlJJwZkGmyFT3SRq r5faZPArIONWHvVxYR7e6PBzUV/MR3P9nSPScoi8tpsR9BYo3a0CqW1H3oRee2n0vV/T /hvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=cv8GrsWX7GRj+2m6As2GyfVywveUU9AXudjqr76MyeE=; b=RbgT1gOKnSALZiViVg9nDemk85UFMAf7VizPbSi3DMy9sv2HvQy4eee0VJ2+wABQ7J 9DTsY/mSWTrbYW35uMdH7O3216zhC8Re90+npRPhMWtccryRGDkXnEXefU0H6rA9OsD8 +Ri+5XxelYu4eT7FFZfhafrZwdAhA3BHG759bH3fFz0R1RyvWZQgheuSwBGeWH97uVaB wybR+cwJ40J1WQxhe3gpj1gpNW6dfEMu1US06mvkTANc4S/czQAhOEpEb3zrrqRvlr/3 zTNeJ9KAnGyM2D+QZXAaBddX2q9N5wGFMrs2Jd1BFUDONuC/Cu9Y7SMcxW73E4YHpYXR YbeQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si2615112pgc.381.2018.06.20.13.24.05; Wed, 20 Jun 2018 13:24:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933357AbeFTUWm (ORCPT + 99 others); Wed, 20 Jun 2018 16:22:42 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:42492 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933085AbeFTUWk (ORCPT ); Wed, 20 Jun 2018 16:22:40 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 419x8W206gz9ttmc; Wed, 20 Jun 2018 22:22:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Tndj5VldOE2z; Wed, 20 Jun 2018 22:22:35 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 419x8W1RMSz9ttmD; Wed, 20 Jun 2018 22:22:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8281D8B83D; Wed, 20 Jun 2018 22:22:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id lYdXz4YwVzwS; Wed, 20 Jun 2018 22:22:39 +0200 (CEST) Received: from po14934vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EE5328B82D; Wed, 20 Jun 2018 22:22:38 +0200 (CEST) Subject: Re: [PATCH 11/11] crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK To: Kees Cook , Herbert Xu Cc: "Gustavo A. R. Silva" , Alasdair Kergon , Arnd Bergmann , Eric Biggers , 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 References: <20180620190408.45104-1-keescook@chromium.org> <20180620190408.45104-12-keescook@chromium.org> From: Christophe Leroy Message-ID: <6537de88-cd81-1c96-afc0-45af17a07729@c-s.fr> Date: Wed, 20 Jun 2018 20:22:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180620190408.45104-12-keescook@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/20/2018 07:04 PM, Kees Cook wrote: > In the quest to remove all stack VLA usage from the kernel[1], this > caps the skcipher request size similar to other limits and adds a sanity > check at registration. > > [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com > > Signed-off-by: Kees Cook crypto/echainiv.c: In function ‘echainiv_encrypt’: crypto/echainiv.c:88:1: warning: the frame size of 2120 bytes is larger than 1024 bytes [-Wframe-larger-than=] crypto/authenc.c: In function ‘crypto_authenc_copy_assoc’: crypto/authenc.c:197:1: warning: the frame size of 2120 bytes is larger than 1024 bytes [-Wframe-larger-than=] crypto/authencesn.c: In function ‘crypto_authenc_esn_copy’: crypto/authencesn.c:194:1: warning: the frame size of 2120 bytes is larger than 1024 bytes [-Wframe-larger-than=] crypto/algif_aead.c: In function ‘crypto_aead_copy_sgl’: crypto/algif_aead.c:90:1: warning: the frame size of 2120 bytes is larger than 1024 bytes [-Wframe-larger-than=] Christophe > --- > include/crypto/internal/skcipher.h | 1 + > include/crypto/skcipher.h | 4 +++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h > index e42f7063f245..5035482cbe68 100644 > --- a/include/crypto/internal/skcipher.h > +++ b/include/crypto/internal/skcipher.h > @@ -130,6 +130,7 @@ static inline struct crypto_skcipher *crypto_spawn_skcipher( > static inline void crypto_skcipher_set_reqsize( > struct crypto_skcipher *skcipher, unsigned int reqsize) > { > + BUG_ON(reqsize > SKCIPHER_MAX_REQSIZE); > skcipher->reqsize = reqsize; > } > > diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h > index 2f327f090c3e..25294d0089b2 100644 > --- a/include/crypto/skcipher.h > +++ b/include/crypto/skcipher.h > @@ -139,9 +139,11 @@ struct skcipher_alg { > struct crypto_alg base; > }; > > +#define SKCIPHER_MAX_REQSIZE (PAGE_SIZE / 8) > + > #define SKCIPHER_REQUEST_ON_STACK(name, tfm) \ > char __##name##_desc[sizeof(struct skcipher_request) + \ > - crypto_skcipher_reqsize(tfm)] CRYPTO_MINALIGN_ATTR; \ > + SKCIPHER_MAX_REQSIZE] CRYPTO_MINALIGN_ATTR; \ > struct skcipher_request *name = (void *)__##name##_desc > > /** >