From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796423867; b=nFobmnN+8LnKmrEOSIK+4/j5T2vDL0w0XMQS38L+gpVNdhNqqRtIp2NpMedYiMjhHJms qhIroc9xAHLZf8lnaeKXroD9oHavRRnZP0ceh5bITOXJmMzdLEr03EsjWDW0oiC5LrIyM mxkr32+xcx0rPHNcD2NNQ5kN0VNUmFh0XU58ujEBmiCSRKso+Ts0PhF82cWyNrt0Pb/tR /i2AUBoTU/FKbpR+nEWf5Fxdbk6Us+iJ6RhAK5niyAbZEn1KBhYaP87QzLWYoVpZP9Xf4 XjJ0XDCFALhAt8zhPE57AY8CN1wOWnb2ZwUy2wMeSDC0JdpVhx6gVa3HAdDUvKtbDgg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796423867; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=Zwh7l2m98STQ1AfSyn27OJuxKUdzQ3Ga7en3jFq4Prg=; b=2ZM8CgtD6XaCBvBhUU4ZBn1/Bedju0XWda7ZTHTkH/Ccu1e63743Kek09bCLSIt4OCom LCQ4HGbgO2POsD4QXgjooi7QWYszGf8qFNYDoYVh4VBw73MYKC1mXF5V0/cl3Kr34ammd Q3L3QReBikYGlqSyKs/7pmwm2HlILz3WP7a5DB35GliP3j7eKwe6/M99wZNCS74qg13gw KtrSdMUf3Kap+HeQlTd/OlDUscMJnE0rnFHmQYNFP/8UE8MokzfLqAx5Hp2plYuGjWCD8 /G5K7vBQf8ZQadxCVk9Wml+AbDjQ9gXIOoglSsSGLlZNT6AMYyDCSkhbmu3PAj2UF2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=gSoup3NE; arc=none smtp.remote-ip=195.10.208.46 Received: from mout-b-106.mailbox.org (mout-b-106.mailbox.org [195.10.208.46]) (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 E3EBA606A322; Fri, 4 Dec 2026 22:37:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3EBA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=gSoup3NE Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-106.mailbox.org (Postfix) with ESMTPS id 4jh5wd6SVrzNlQ3; Fri, 04 Dec 2026 23:37:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796423857; 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: in-reply-to:in-reply-to:references:references; bh=Zwh7l2m98STQ1AfSyn27OJuxKUdzQ3Ga7en3jFq4Prg=; b=gSoup3NEw/dwxLdF7Ba2Uc7U391nIvWDHa531CwfBTLnSsaU0WoYzc7gVZ10a5W8bLXuHu 93cTe2XMwXae071X/TlYkJJWZithNGe2cd8ENiAnLw648zI4vPuhtgXSdEWVw5y3KbhgEB wXL+nI63v8XeVcyyiW+uVX1dgUcdgT+Mnow9DsayjyFOabHQgLXTyldHqRlqNacCZTk5Fe 98Bt9DIkIRpuZdI9rsMQ45diQMQCfem/qWZq05zU9GMK9QB0A2nh3z03FgS0nqiIJtiy10 7CdsJrq4tHj/ZMtUFW5lNHrKlX4zUtcoDSV3femfRQs2HKZZfFWKJ5Pg78POAw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=antonio@mandelbit.com From: Antonio Quartulli To: Herbert Xu , Steffen Klassert Cc: Antonio Quartulli , "David S. Miller" , Wang Jinchao , linux-crypto@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/2] crypto: pcrypt - Make sure the instance can be found by the requested name Date: Fri, 4 Dec 2026 23:37:32 +0100 Message-ID: <20261204223734.4111964-2-antonio@mandelbit.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204223734.4111964-1-antonio@mandelbit.com> References: <20261204223734.4111964-1-antonio@mandelbit.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-Rspamd-Queue-Id: 4jh5wd6SVrzNlQ3 A pcrypt instance keeps the cra_name of the algorithm it wraps and derives its driver name from the inner driver name. When pcrypt is requested with a generic inner name, neither name matches the request, so the new instance cannot be found and the lookup is retried. The next instance then wraps the previous one, now the highest-priority match, until the driver name overflows. Refuse to create an instance that cannot be found under the requested name, i.e. require the inner algorithm to be named by its driver name. Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper") Cc: stable@vger.kernel.org Suggested-by: Herbert Xu Signed-off-by: Antonio Quartulli --- v2: - check that the instance can be found under the requested name instead of refusing to wrap a pcrypt instance (Herbert) crypto/pcrypt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index 9f372442981e..292466f92063 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c @@ -226,8 +226,16 @@ static void pcrypt_free(struct aead_instance *inst) } static int pcrypt_init_instance(struct crypto_instance *inst, - struct crypto_alg *alg) + struct crypto_alg *alg, const char *name) { + /* + * The instance keeps the cra_name of the inner algorithm, so it can + * only be found under the requested name through its driver name. + * That requires the inner algorithm to be named by its driver name. + */ + if (strcmp(alg->cra_driver_name, name)) + return -EINVAL; + if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME, "pcrypt(%s)", alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME) return -ENAMETOOLONG; @@ -248,6 +256,7 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb, struct aead_instance *inst; struct aead_alg *alg; u32 mask = crypto_algt_inherited_mask(algt); + const char *name; int err; inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); @@ -265,13 +274,15 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb, if (!ctx->psdec) goto err_free_inst; + name = crypto_attr_alg_name(tb[1]); err = crypto_grab_aead(&ctx->spawn, aead_crypto_instance(inst), - crypto_attr_alg_name(tb[1]), 0, mask); + name, 0, mask); if (err) goto err_free_inst; alg = crypto_spawn_aead_alg(&ctx->spawn); - err = pcrypt_init_instance(aead_crypto_instance(inst), &alg->base); + err = pcrypt_init_instance(aead_crypto_instance(inst), &alg->base, + name); if (err) goto err_free_inst; -- 2.56.1