Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1231693ybt; Thu, 9 Jul 2020 01:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz30XDEqq/UBK8AyOJzp5miBt51CHVguZn8XF7vSXoD6NYZqbcsYBS9im32x08pP1AjbJen X-Received: by 2002:a17:906:4d4c:: with SMTP id b12mr54254602ejv.506.1594284709941; Thu, 09 Jul 2020 01:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594284709; cv=none; d=google.com; s=arc-20160816; b=TX0eSf8g2YsgwPi0GLjuPFNivN8wPUct13nC4ANfKxGgh4FOKAuLxpU86GNAx2khx9 /UmPHpKgrVon8dtKTayqZUTH0+o1KnzR/LaWoZC99jylBAkbb1+xWS842B2ECCO+LNWD QHdO0bdPQA5L21K9us3G4YjYpNFWrJrvRCCTmZ+0VA6xg/zxoDCH+jEICsqneYv9abys 0fobMQB0ln+N1sBXLhms4sWv47X+u9bzh0krpW5UZwz4Ucw8XCMdSgn+YsMMk1INpdoB u6kbe5mDvh49QqHjnPwGY7fX5g2MJF/NcDtBUWM4RXHOPflRYctkoqcDdMMYMzxytiqH EIlA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=gNSIkUvsq+DFDUCkzYWTuhb1DSUaYozf6mFrP5frst0=; b=buPHe8QDFYW59agxf8Ck2AJMiOPtXWoyCGeZ7ngezS46J/5DdYwXdgBti5NxAHAsz5 QRiVPjVGyCE1bnocuAQQgjE7inknXan9qPCVscwL5qbOhOWnGGcrsKeQIRKnfxaF2HZm Oh+V0OCm0vSIX2vmqD/C+tBa9pZnR6YK1Omfbfbg6xrhob1PJQS5CzCAf+NzmZCbug2j Jkbu556d66fck2g6sIQHN3KTRJ1szW/yTRrv4bQH/JCG+QuUJuOiE1VeJ+szAQhR8R0j wYsGZU5IlKtle47EzaK+6gio0LFzVE0tBycavrurQp2w0my8uUG/rAFC2JvO1Erjjev0 ggEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aujcqdQC; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si1484131eje.33.2020.07.09.01.51.26; Thu, 09 Jul 2020 01:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aujcqdQC; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbgGIIvX (ORCPT + 99 others); Thu, 9 Jul 2020 04:51:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgGIIvX (ORCPT ); Thu, 9 Jul 2020 04:51:23 -0400 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76BBB2067D for ; Thu, 9 Jul 2020 08:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594284682; bh=iOQWTCgIGURnZ4pFe02nC8Sn658NBNaRKoP7uXDodPI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aujcqdQC5TrZN0/ICl5aTL0HX8dGjW6mT+1opqhdjKXGuUtClAaCYMHtnHUrvnfP5 4PJo/kf/3geBZOySwGy97AZqMUpqHoq8cEQXvFO95SK/eY9QRB/gi8giYZq9c2/7/v xwbNRS53HLQXSMhjV8dlvQt3wtAfv8yLpvHDFsFM= Received: by mail-ot1-f44.google.com with SMTP id c25so1170243otf.7 for ; Thu, 09 Jul 2020 01:51:22 -0700 (PDT) X-Gm-Message-State: AOAM530ynateq4vqFWsmei7j/iYKzUBJAdiSq7Gw7AArG1Jlo3nzbvVQ 84Ktq3jZapkNqsW2GyNUa3QIJtZH61m4bTb7vfA= X-Received: by 2002:a9d:6e85:: with SMTP id a5mr12208065otr.90.1594284681780; Thu, 09 Jul 2020 01:51:21 -0700 (PDT) MIME-Version: 1.0 References: <20200629073925.127538-1-ardb@kernel.org> <20200629073925.127538-6-ardb@kernel.org> <20200709082200.GA1892@gondor.apana.org.au> In-Reply-To: <20200709082200.GA1892@gondor.apana.org.au> From: Ard Biesheuvel Date: Thu, 9 Jul 2020 11:51:10 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/5] crypto: arm/ghash - use variably sized key struct To: Herbert Xu Cc: Linux Crypto Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, 9 Jul 2020 at 11:22, Herbert Xu wrote: > > On Mon, Jun 29, 2020 at 09:39:25AM +0200, Ard Biesheuvel wrote: > > Of the two versions of GHASH that the ARM driver implements, only one > > performs aggregation, and so the other one has no use for the powers > > of H to be precomputed, or space to be allocated for them in the key > > struct. So make the context size dependent on which version is being > > selected, and while at it, use a static key to carry this decision, > > and get rid of the function pointer. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/arm/crypto/ghash-ce-glue.c | 51 +++++++++----------- > > 1 file changed, 24 insertions(+), 27 deletions(-) > > This introduces some new sparse warnings: > > ../arch/arm/crypto/ghash-ce-glue.c:67:65: warning: incorrect type in argument 4 (different modifiers) > ../arch/arm/crypto/ghash-ce-glue.c:67:65: expected unsigned long long const [usertype] ( *h )[2] > ../arch/arm/crypto/ghash-ce-glue.c:67:65: got unsigned long long [usertype] ( * )[2] > ../arch/arm/crypto/ghash-ce-glue.c:69:64: warning: incorrect type in argument 4 (different modifiers) > ../arch/arm/crypto/ghash-ce-glue.c:69:64: expected unsigned long long const [usertype] ( *h )[2] > ../arch/arm/crypto/ghash-ce-glue.c:69:64: got unsigned long long [usertype] ( * )[2] > That looks like a sparse bug to me. Since when is it not allowed to pass a non-const value as a const parameter? I.e., you can pass a u64[] to a function that takes a u64 const *, giving the caller the guarantee that their u64[] will not be modified during the call, even if it is passed by reference. Here, we are dealing with u64[][2], but the same reasoning holds. A const u64[][2] formal parameter (or u64 const (*)[2] which comes down to the same thing) does not require a const argument, it only tells the caller that the array will be left untouched. This is why the compiler is perfectly happy with this arrangement.