From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332698; b=hxy2vvaKUmSYXsywSGOBTRhVkqBL4UnOOdus1TzlLg5LDmb7nJvqELVvc2dpn/74u/wm QU7uGQ2rVeZ4iSE86TqcQ5KM3XWB5VlSs8t0ebMfsOuE47pSF855NUAKqKXoLM3T2e45f S8+ZssHmrRtetGfzbHDK0+uJdQRVc+A/h/n6H/QWzrOvtYodOUKZADs1sXVbewsvWlFKR lUTPUL1HrQoMtsglSnwp+ovjW1KtyG/fEP8gKPfIrYpRCidVir5n4Y75LjC08yQ4jba8X YGqh7ekIfAyCPOVSkgXxfjz7i2A7lYRrPU+ygs0uR7y8TKQYGYKTfOCPBpmmqMHfVqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332698; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=cjd/yx0L/B8NnWsZM2TC8mIIh7Xq8+z9Y08OsGZboAs=; b=PlKTZ0+nrQGfg/t7tCH0rIpLNaUaBeufvVu2iHeBC1y5Nsx4TeNhUB/cX6P6T4gcegmf Q7k50FxoslsbVQ/maEuNBASZ04jb3IkTVG/OBKUo35Swfoa/5QhonujlqAWQ9JOddGRAF wwWdFRzt7sIwp+dgF7uM5d6JismAOTHzdcPrhZMiamKWsJBI+EOsU6CHDxjyOah0+jKG7 pFPpRHMD3QIbDaKdOyGG/nl3VJkA0jE7W1bztVpXCp4vSz0xKBsSp2YbhIav3qf40UoI7 ZKMbPIwuJ2iq1MAK62Dr2TO+iHjX9KXWEnbW9mebbm6BwMOzil1vwiFt4V3D4ytcI9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WRN+Y+nD; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B337606A322; Thu, 3 Dec 2026 21:18:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WRN+Y+nD Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF96B1F000CE; Thu, 3 Dec 2026 21:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796332697; bh=cjd/yx0L/B8NnWsZM2TC8mIIh7Xq8+z9Y08OsGZboAs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=WRN+Y+nDaH82GA5JnZ8++1hTE7wjWJtD7nz2zqp15U1HBZVaX6Y33vgPeAcq3warY ejtBDrF85o4crTSEehsb64MAn10eRRXTu0IJVKquIRjxacsQN7XA2ZNbPgue8ZnNPS y0Iy96MQ2ciTsmBYz9pWvvK6uVS6iMoSzGg4+Aft3emIXEtzlrestElofb5zviVToc nSYDrZjAn3WpC/lOPFrGlfCER0d1OVDqB+uDyWC7+c0jWVEEC/wwtEEajCUYdOUYVh 5lKHbwNtsCUIrqADN61NYpQOMyDL+3Bk0z/SbFoxa0rLu1uMAgDg2yVeo4C/3+5QD4 65wqiV2G0p9fQ== Date: Thu, 3 Dec 2026 21:18:16 +0000 From: Eric Biggers To: Bruno Meneguele Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, stable@vger.kernel.org Subject: Re: [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check Message-ID: <20261203211816.GA601100@google.com> References: <20261203210119.42352-1-bmeneg@redhat.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203210119.42352-1-bmeneg@redhat.com> 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 setting > 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, causing 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 NVIDIA > Tegra: > > alg: hash: failed to allocate transform for tegra-se-cmac: -22 > alg: self-tests for cmac(aes) using tegra-se-cmac failed (rc=-22) > > With this commit these templates pass CRYPTO_ALG_TYPE_SHASH|CRYPTO_ALG_REQ_VIRT > instead, so requests that need REQ_VIRT set are accepted, and requests that 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 == CRYPTO_ALG_TYPE_SHASH || type == CRYPTO_ALG_TYPE_SCOMPRESS) type |= 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. 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. - Eric