Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2282827pxb; Fri, 8 Oct 2021 04:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNrtMBNTzCNlYVYl0MShr31VHgrbO9j0DFR8fHyi1tw55jb75jXOkt5e9R0zCT5l5rC+bT X-Received: by 2002:a17:906:d541:: with SMTP id cr1mr3909756ejc.81.1633694126146; Fri, 08 Oct 2021 04:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633694126; cv=none; d=google.com; s=arc-20160816; b=DhCQo14JWAqAv8RjYAvJgxeYsJ+TcNCXNGYDKmdWDqqPO9Rq0MOCyiORElkxNsjrZF 9B2TnuHtbZYBXQHNpOPVy97LlyWOz4zLsPIQvGsuB4hNRBEiTm9nU5BVCxq0LzwbOZTD e+aMVu6E5xEA+tsztCh2Xd0zmPmHSm1FfsXJnhhqCqABTv6Mt0GjwTXQ/rp4KmYmU67U CDoXftEDbqrKYlkOx3gK6OWW1L4GdSjyLt+IHrPr3Rq7Aet4ceXTo0nTyK6mCJ7dHmMk qnyxlvFJRAdEwueVFIHsgL9kb/UYjmZkB3Z1om4Y9z5BGvhu9bX+NQKA1JUG+W+CiWla Kk3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=I9DwTNeoTx6WeDxu7+zOBt/pP5D0guijV7mD6tzbP3s=; b=TUl6R3dJZ604yl3N0dUn9NNlL0e70NQM9PibxMrDSfS6w+7y5pqVKV2FHAxcz/bpEP mxI6T6NyfKzjR5txjO3nllgEbWA+HADXDdoIy5r2wUeTKjfiX5s1YCQbwOys+V6IT2NI fkrCDdICHE9Ou0GxdMeEmDqIoomn09GWd3I6FH+2GzF5KzJVA4/1poOj0m3FQNe7hLaI bM2gkteFWkaIhM0vkedLhh2A9/3xVk27MuFt5E7yxR6C8+o3Ur2VOmBKtfNLdDFq6lxw 7MWs8b1cqUG6DdBIxnMnWO5H+FevzHv5pihZjL70LO9NhfJCr3Gpqo9zCfjXuMUaMwmj 8a8A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si3303728edw.225.2021.10.08.04.54.56; Fri, 08 Oct 2021 04:55:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240999AbhJHL4l (ORCPT + 99 others); Fri, 8 Oct 2021 07:56:41 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:55910 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240776AbhJHL4d (ORCPT ); Fri, 8 Oct 2021 07:56:33 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.92 #5 (Debian)) id 1mYoSS-00039z-4U; Fri, 08 Oct 2021 19:54:36 +0800 Received: from herbert by gondobar with local (Exim 4.92) (envelope-from ) id 1mYoSO-000705-6v; Fri, 08 Oct 2021 19:54:32 +0800 Date: Fri, 8 Oct 2021 19:54:32 +0800 From: Herbert Xu To: Nicolai Stange Cc: "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan =?iso-8859-1?Q?M=FCller?= , Torsten Duwe Subject: Re: [PATCH 8/8] crypto: api - make the algorithm lookup priorize non-larvals Message-ID: <20211008115432.GC26495@gondor.apana.org.au> References: <20211003181413.12465-1-nstange@suse.de> <20211003181413.12465-9-nstange@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211003181413.12465-9-nstange@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sun, Oct 03, 2021 at 08:14:13PM +0200, Nicolai Stange wrote: > crypto_alg_mod_lookup() invokes the crypto_larval_lookup() helper > to run the actual search for matching crypto_alg implementation and > larval entries. The latter is currently considering only the individual > entries' relative ->cra_priority for determining which one out of multiple > matches to return. This means that it would potentially dismiss a matching > crypto_alg implementation in working state in favor of some pending > testing larval of higher ->cra_priority. Now, if the testmgr instance > invoked asynchronously on that testing larval came to the conclusion that > it should mark the tests as failed, any pending crypto_alg_mod_lookup() > waiting for it would be made to fail as well with -EAGAIN. > > In summary, crypto_alg_mod_lookup() can fail spuriously with -EAGAIN even > though an implementation in working state would have been available, namely > if the testmgr asynchronously marked another, competing implementation of > higher ->cra_priority as failed. > > This is normally not a problem at all with upstream, because the situation > where one algorithm passed its tests, but another competing one failed to > do so, would indicate a bug anyway. > > However, for downstream distributions seeking FIPS certification, simply > amending the list in crypto/testmgr.c with ->fips_allowed = 0 entries > matching on ->cra_driver_name would provide a convenient way of > selectively blacklisting implementations from drivers/crypto in fips > mode. Note that in this scenario failure of competing crypto_alg > implementations would become more common, in particular during device > enumeration. If the algorithm in question happened to be needed for e.g. > module signature verification, module loading could spuriously fail during > bootup, which is certainly not desired. > > For transparency: this has not actually been observed, I merely came to > the conclusion that it would be possible by reading the code. > > Make crypto_alg_lookup() run an additional search for non-larval matches > upfront in the common case that the request has been made for > CRYPTO_ALG_TESTED instances. > > Signed-off-by: Nicolai Stange > --- > crypto/api.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) It's not clear that this new behaviour is desirable. For example, when we construct certain complex algorithms, they may depend on a generic version of that same algorithm as a fallback. We do not want users to get the generic version while the better version is being tested. Can you please explain what your failure scenario and perhaps we can come up with another way of resolving your problem? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt