From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796331695; b=fEOO9FDOv1YO0sgnDSonQB4DSL3a2EvNgobJHxStfycXKlJh7Amw4wROwYwGwNPBpR7T PN5mhwkxF4qr/nlmZR4spkC4EkfgjEThgU3jj2Xd5z856ZcVLw6dV+4AB9wD2ItYxJmpC 4DWJ7nbYiHTIDyBpHtpp/g9KY6OL6WJl9buEZz2BUhRtN0745fEO64FIkQCfr1PNYWYcO CQPvQqL+DqO5hiV42zOeiX9LMYNNX163iOhiiI+8Md05za+tVfQx3X76RXj+f+t7N7TRW qccbks6GMLtySemix6Aids5KXUve9rmo0qwArmk9Kk9b9q8Eey5d+e8tC58lNXSzI6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796331695; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:MIME-Version:Content-Transfer-Encoding:X-Scanned-By; bh=T9P1ckWKSGS3m0MdBT3pbCq5fNrmoiHKQPzVEN5Q464=; b=1KoTBzQ6tAhBqGLaF2B1FJitO4LNcI6o2pVJNMXt7Vhd3WWhU+rx0g3+JiM2U0STRt5V 8wrfanhED7SVYMSrJ4O3CfA+6O8L4dXAaGfEHeagdf5i5df9qeECBsQVsHG06Bi12oRDZ 0er8uP81OR9RxpTvNF+aqzVw7iyAmqRVt/SgtPkL0IIVZUqyZTAUNGHVRbmfnBIG6/vdo lg4ukLzSOlBs1CwPgpH38W0aVZWDdzq4ArJK8hYEFqpyBR8QnECeiOn87D3aiHGdAvyxo XRqD+YoKCClcHq05huCUoCdTUtEGN3qItFcZrESKyCjG1J3qSwIF3z6h7aLe5Hf6R4g== 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=Lpxh0UwJ; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 7AF63606A322 for ; Thu, 3 Dec 2026 21:01:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7AF63606A322 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=Lpxh0UwJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796331694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T9P1ckWKSGS3m0MdBT3pbCq5fNrmoiHKQPzVEN5Q464=; b=Lpxh0UwJ3ciUB3J36/bbWCdaWalSjx9HYxsIbpiPRIPq+hoQWYctl8I8WuW1bEuoA6WIBO 1iNBeSnvSPgxZ0YvBb9uMHPdQrLv9gXAxb4d6WuYzfdZo0bTh2KOTepxRi/T2ad3ALMLG6 U5rVv7mGjeKbre1/ar0zQhT/sq9GdLQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-68YGOMeTNR-YoAj8rJHnxQ-1; Thu, 3 Dec 2026 21:01:31 +0000 X-MC-Unique: 68YGOMeTNR-YoAj8rJHnxQ-1 X-Mimecast-MFC-AGG-ID: 68YGOMeTNR-YoAj8rJHnxQ_1796331690 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF08C18A5D94; Thu, 3 Dec 2026 21:01:29 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6CA7E18088A5; Thu, 3 Dec 2026 21:01:28 +0000 (UTC) From: Bruno Meneguele To: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, ebiggers@google.com, Bruno Meneguele , stable@vger.kernel.org Subject: [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check Date: Thu, 3 Dec 2026 18:01:19 -0300 Message-ID: <20261203210119.42352-1-bmeneg@redhat.com> 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-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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(-) diff --git a/crypto/ccm.c b/crypto/ccm.c index 916441e4f2b8..250af56cfe1f 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c @@ -852,7 +852,8 @@ static int cbcmac_create(struct crypto_template *tmpl, struct rtattr **tb) u32 mask; int err; - err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask); + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH | + CRYPTO_ALG_REQ_VIRT, &mask); if (err) return err; diff --git a/crypto/cmac.c b/crypto/cmac.c index 83e58937f013..74786612a6f1 100644 --- a/crypto/cmac.c +++ b/crypto/cmac.c @@ -165,7 +165,8 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb) u32 mask; int err; - err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask); + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH | + CRYPTO_ALG_REQ_VIRT, &mask); if (err) return err; diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 6c5f6766fdd6..50f14bd7d88d 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -132,7 +132,8 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb) u32 mask; int err; - err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask); + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH | + CRYPTO_ALG_REQ_VIRT, &mask); if (err) return err; -- 2.55.0