From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796333809; b=rCikuXMA+69fNnVhmDH1KnV0KhkUb64h0gcJ1e7X2YAjQyo+TtTdkz6byo8/SsM1X1E2 xzpHygykgOjlGI7ZqDQ08G/DWYLdLLEgpn1ifG0oVp5y8Ly5LHQS5tLB2ms11ma1pGKvW 8Ve0SOQa3gZXNw80fS4qyGbAwx2ApL7tHhM3KhTWDasrfxT8Udo0Uwaf65rRFHRa/fGOW ZHfeyQqwQTz0Mhii2Za1CMp9QqreJxFvVNAzgoCyqtWqcqQqwHmcOPa0UEJlWuewJnWwr XprUFXcGVM4uyzReGr8tnqpMoirndxHNaDV9uAjEGKiT9nyBr3C40B6UgcFIVa3pwBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796333809; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Mime-Version:Content-Type: Date:Message-Id:From:To:Subject:Cc:References:In-Reply-To: X-Scanned-By; bh=Vfp2kYf8/L0aUgsr0lCIn5Ih/W8SIShCdvdXrqzCQnc=; b=Ng2dWNfXaCHHnhLzXE5zGNilLnrINNU0ZBEGEXmPtJqvEfIaiZZrg0d42NywHDyIGrf+ FXeIKGySHpvXbO9/5kGA+TzJzSP4j/6gNZNE/y11Z2yeGvWy9hG5iKGozEW861zKF6Cfw J8n6rPHu8rOar2sZDODePecUpY1clbLEcko6vnzJPo7G6n58+sdW6SIO3D9gUziwC1rpM 1ThCuEq/wX2l46zQTjt6YnKdYcS56x/YKFj1+S99b/bvgJ85mWOiumCotIiCLdrVyd31D ZrSn/h9MwlJcveMSJnwfuJPxtgLq9QOsl3/58Z51i4xICxxolDlzsZAgpdaPa99iWqA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z1Ms3EzS; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0F93606A322 for ; Thu, 3 Dec 2026 21:36:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D0F93606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z1Ms3EzS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796333807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vfp2kYf8/L0aUgsr0lCIn5Ih/W8SIShCdvdXrqzCQnc=; b=Z1Ms3EzSW6fIYCwCUAp4GSGrA2WoWjGr7pGZsfV557iAb1EuqD5vab3joqoHxltHgHgFFt qbSGyym8KY5hvKIH63YuQ5Sb2V/NjykPJd+Q4Ml16KKQpJM/4QFQ5MnGml8ZlQL0cPUVNj N5UN3+LDXNAmD0yXavc7hISqexQAQOQ= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-0YXBaEc4N2-5Icv3JprwLw-1; Thu, 3 Dec 2026 21:36:43 +0000 X-MC-Unique: 0YXBaEc4N2-5Icv3JprwLw-1 X-Mimecast-MFC-AGG-ID: 0YXBaEc4N2-5Icv3JprwLw_1796333801 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A47D18FE266; Thu, 3 Dec 2026 21:36:41 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A1C03002D1F; Thu, 3 Dec 2026 21:36:40 +0000 (UTC) X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: multipart/signed; boundary=cb4ea5142ce0fa2d0ef33c695446e982b73e5d960e3af97f2e6ea837f9ee; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Thu, 03 Dec 2026 18:36:38 -0300 Message-Id: From: "Bruno Meneguele" To: "Eric Biggers" Subject: Re: [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check Cc: , , , , References: <20261203210119.42352-1-bmeneg@redhat.com> <20261203211816.GA601100@google.com> In-Reply-To: <20261203211816.GA601100@google.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 --cb4ea5142ce0fa2d0ef33c695446e982b73e5d960e3af97f2e6ea837f9ee Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed On Thu Dec 3, 2026 at 6:18 PM -03, Eric Biggers wrote: > On Thu, Dec 03, 2026 at 06:01:19PM -0300, Bruno Meneguele wrote: >> Since commit 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API= "), >> crypto_ahash_init_tfm() allocates a fallback for every async driver by s= etting >> CRYPTO_ALG_REQ_VIRT flag in both type and mask. >> >> However, the cmac, xcbc and cbcmac templates validate the request with: >> >> crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask) >> >> which compares the whole flag word, including the previously set >> CRYPTO_ALG_REQ_VIRT flag, which is now missing during comparison, causin= g it to >> return -EINVAL. >> >> The error propagates to crypto_ahash_init_tfm(), even before a driver's = own init >> runs, causing the driver to fail on its self-test. For instance, on NVI= DIA >> Tegra: >> >> alg: hash: failed to allocate transform for tegra-se-cmac: -22 >> alg: self-tests for cmac(aes) using tegra-se-cmac failed (rc=3D-22) >> >> With this commit these templates pass CRYPTO_ALG_TYPE_SHASH|CRYPTO_ALG_R= EQ_VIRT >> instead, so requests that need REQ_VIRT set are accepted, and requests t= hat need >> it clear, are still rejected. >> >> Fixes: 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API") >> Cc: stable@vger.kernel.org >> Signed-off-by: Bruno Meneguele >> --- >> crypto/ccm.c | 3 ++- >> crypto/cmac.c | 3 ++- >> crypto/xcbc.c | 3 ++- >> 3 files changed, 6 insertions(+), 3 deletions(-) > > The "Handle partial blocks in API" design is still a bit perplexing to > me. But I *think* a better for this issue would actually be > crypto_check_attr_type() itself: > > if (type =3D=3D CRYPTO_ALG_TYPE_SHASH || type =3D=3D CRYPTO_ALG_TYPE_= SCOMPRESS) > type |=3D CRYPTO_ALG_REQ_VIRT; > > That would be consistent with the documentation for > crypto_check_attr_type()'s type parameter, which says it's the algorithm > type. It doesn't say that you can pass other flags too. It would also > ensure that other templates like hmac-shash aren't missed. > Well pointed and agreed. I'll prepare a v2. > Of course, if we take a step back, this issue also makes it clear that > ~6 drivers in drivers/crypto/ (the ones that register one of the > affected algorithms) haven't been tested in the last 18 months. Such > untested crypto drivers do not belong in the kernel in the first place. > I found it while testing NVIDIA Tegra Secure Engine driver and made me wond= er the same thing (I do have another patch to submit specifically for this dri= ver). -- Bruno Meneguele PGP Key: http://bmeneg.com/pubkey.txt --cb4ea5142ce0fa2d0ef33c695446e982b73e5d960e3af97f2e6ea837f9ee Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFGBAABCgAwFiEEdWo6nTbnZdbDmXutYdRkFR+RokMFAmsR4OYSHGJtZW5lZ0By ZWRoYXQuY29tAAoJEGHUZBUfkaJDQl8H/A2GstHfnoI4pl9qQFqulrr8stI4ixa6 PtycfaAVoK3CDu2AC7YySwRIJ+llTIoh29nIyQHFFQdT8XAIG1Jo+n3ckfKDDtCm 1AvDderOgV4pRb6FNE3HClpTl/ehtr98MA4+FauXuCrFxa6RBKoOLbMANVZlkXm2 8vRl9stWEj//We2E/+t9AcjIzkaqox6a5DUCEIIJFUQ1AiXgYObNGNf5+spm5SPz PCkqqxRnDe6MJTz9PaiXeaF4gRJb+ceuMD79GpOGJ5Vojr6RzIBo8EPr/iTk5T12 qlSf0lzdXhUjBS9npMOEM1w6izc+itPkrSsifcNXeSKgjuvJi1wttU8= =EFkd -----END PGP SIGNATURE----- --cb4ea5142ce0fa2d0ef33c695446e982b73e5d960e3af97f2e6ea837f9ee--