Received: by 10.213.65.68 with SMTP id h4csp2700195imn; Mon, 9 Apr 2018 07:42:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+DXRKSoj1t32Fy/o7Sed4APklJfLQxtrkfQtwg9dKte4q2lOGlfiDh9mEP+37xBgUG79oC X-Received: by 10.167.128.141 with SMTP id v13mr29530023pff.147.1523284977134; Mon, 09 Apr 2018 07:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523284977; cv=none; d=google.com; s=arc-20160816; b=uiSMtZfIIKS8csnUKxIXATZ1NNSZ/S27lnsTDz9wSDHWvVI8HNbI/iSI0UE7doRtS1 j64NlTN2oc4jS427JkuGgw0tn6/YdVr/LGgouH1z55wXg6l86iBur/wLYfUiPfMfz6P6 WwdYSWryMSnqUHDT+G2uMFBiPvszcoljVjR5orKi1FwtvAldw/laKvI1fJc3X+p/WMYy nc9IRRrOLUa6qyuNuZmos2TDFU2IlxH3O8bBKyuzOC9QvsqMK2JCn1MwwwbKk+2k23EO fqEi34Wk5IB7ukmXL8PKiI+CIrUBoLoLP1O7bJPiJluEb7oHHsUYEj/Jroc+a3Y8aHL1 rnvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=btrnXJkRiOtnlOtjokfo+qKle/LNOD4tUCYdyZlTitQ=; b=KoG76f1RsIPfmgpq/8YqBTXYzbsFhSrzrzYljz69HZReZA4x94ZxFUvpII5cHWsc3z wvW8Ao1W3xXCrVSwO7dZLSPgQObRmE9OcurfjfK7nsR/+eVJGUk2AiDsSbgeDzRyp3+U R8Q+vYpyZ/uPpEnQtt77S/wRY4ZQp0JEkW+pdhNADKHLPRdI1k34YYzfeTCWrDZXtJTz Pq2adisn9rAsogw93tAlEtC5jiFlK0RCw0mmxAwfELy5MK+FlYHaZH34JV6SajVHkTz+ kLeC7EnsU68xBSHJXf2V8LCfOg+Z44s4B/PMaftJ0Aq+j3ONQbaZXEV9GY0Yvs7hVC1O YZbQ== 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 v65si299012pgv.807.2018.04.09.07.42.19; Mon, 09 Apr 2018 07:42:57 -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 S1752785AbeDIOe6 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Apr 2018 10:34:58 -0400 Received: from smtp-out4.electric.net ([192.162.216.182]:52893 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752314AbeDIOe5 (ORCPT ); Mon, 9 Apr 2018 10:34:57 -0400 Received: from 1f5Xsf-0003vQ-UP by out4d.electric.net with emc1-ok (Exim 4.90_1) (envelope-from ) id 1f5Xsh-00046D-Th; Mon, 09 Apr 2018 07:34:51 -0700 Received: by emcmailer; Mon, 09 Apr 2018 07:34:51 -0700 Received: from [156.67.243.126] (helo=AcuMS.aculab.com) by out4d.electric.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1f5Xsf-0003vQ-UP; Mon, 09 Apr 2018 07:34:49 -0700 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 9 Apr 2018 15:35:50 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 9 Apr 2018 15:35:50 +0100 From: David Laight To: 'Salvatore Mesoraca' , "linux-kernel@vger.kernel.org" CC: "kernel-hardening@lists.openwall.com" , "linux-crypto@vger.kernel.org" , "David S. Miller" , Herbert Xu , Kees Cook , Eric Biggers , Laura Abbott Subject: RE: [PATCH v2 0/2] crypto: removing various VLAs Thread-Topic: [PATCH v2 0/2] crypto: removing various VLAs Thread-Index: AQHT0AqPFLFjzadDvEuYJrE7teT3QaP4fQXg Date: Mon, 9 Apr 2018 14:35:50 +0000 Message-ID: References: <1523282087-22128-1-git-send-email-s.mesoraca16@gmail.com> In-Reply-To: <1523282087-22128-1-git-send-email-s.mesoraca16@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 X-Virus-Status: Scanned by VirusSMART (s) X-Virus-Status: Scanned by VirusSMART (c) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Salvatore Mesoraca > Sent: 09 April 2018 14:55 > > v2: > As suggested by Herbert Xu, the blocksize and alignmask checks > have been moved to crypto_check_alg. > So, now, all the other separate checks are not necessary. > Also, the defines have been moved to include/crypto/algapi.h. > > v1: > As suggested by Laura Abbott[1], I'm resending my patch with > MAX_BLOCKSIZE and MAX_ALIGNMASK defined in an header, so they > can be used in other places. > I took this opportunity to deal with some other VLAs not > handled in the old patch. If the constants are visible they need better names. Maybe CRYPTO_MAX_xxx. You can also do much better than allocating MAX_BLOCKSIZE + MAX_ALIGNMASK bytes by requesting 'long' aligned on-stack memory. The easiest way is to define a union like: union crypto_tmp { u8 buf[CRYPTO_MAX_TMP_BUF]; long buf_align; }; Then in each function: union tmp crypto_tmp; u8 *keystream = PTR_ALIGN(tmp.buf, alignmask + 1); I think CRYPTO_MAX_TMP_BUF needs to be MAX_BLOCKSIZE + MAX_ALIGNMASK - sizeof (long). David