Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2985090pxb; Sun, 3 Oct 2021 11:15:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmK+JfEwQE9Ko5Y7T8znrTW1eTKtU9xh3Yt3dy27fRcjX7NinkROn2aG9h2rNOpUZRtYuH X-Received: by 2002:a63:de51:: with SMTP id y17mr7535558pgi.235.1633284949654; Sun, 03 Oct 2021 11:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633284949; cv=none; d=google.com; s=arc-20160816; b=ICm4GJqX8ODlwq9qqLGDOkCLXemB4Tt/gcjWTR5ujYca84fpzKKw+DWyqfxeiMBWx7 /nH6PE4PY8ERGc23MKc/t/Q41qr5kOSvG7vSAlcv9ObRYR6SCy7uQYnr5VSkAUvVgKn4 yBwJ5gn99kgn2DrXQgotdJF7x1Xv2geTUnmpw/PEia4U65lz0zJu9jCkaslXD9e+b26E 6j9WbkpZWN9w60fzT9P9wrR9hWtz4IyY+ovf35RvIAZTL0wmoHcbm3zTsAhVivLYL/SE rtJqEvJOfAlpjGoEXYzZHhuBGvyeAiY1CI4pgK6tMMKUWzSKlLBMTFPVzrYWgHJxFnRW yGVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=iH2JsL7W0xFKKIPPGaOXY8EOQcn93ljDlGisHT9c2fU=; b=TxkaEEtvkfbfY1LwyXJm5QlSPLLdbwszhfBeyPG7iN9h5XHpVGXg3AcKu+sm0NY0YX atRvCY8RGP3pPzT5YaAGREj877p97O+a9qiJueKxgs5jxOqyjnZP8sapt5oklFaksTOB NfFEYk2pzmDawLfBCxw9Hk2vw55I1CCJ1s+2wz7+H72S985QR2M7fg3wrcZuBKyYyXVc OdSxeYtFD5dQkthMWdjSCunQFFmib7e9cSElgPCWSewZ2Y4RLXho2cZGNGigl15JcVJ/ WceSTsb8767nBQLUeABvTKM2noRq0aqYsw169BhX8+/PJGgedRWYsSrKdyJ6gtD+ufKF BOhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LE2B/ax5"; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c25si14174148pgb.70.2021.10.03.11.15.36; Sun, 03 Oct 2021 11:15:49 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LE2B/ax5"; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbhJCSRA (ORCPT + 99 others); Sun, 3 Oct 2021 14:17:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:50830 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbhJCSQ7 (ORCPT ); Sun, 3 Oct 2021 14:16:59 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 12CD92218C; Sun, 3 Oct 2021 18:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633284911; h=from:from:reply-to: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=iH2JsL7W0xFKKIPPGaOXY8EOQcn93ljDlGisHT9c2fU=; b=LE2B/ax5Jrt6VMxT4z7VrQN2dEWSIOffeumzR30X8ppJhW4Cw6Mq+Bi9TT1qVRIffTzRD8 5um3UEUWndbhFxKlCBrMXVKBLNHVY3l1g5xFgEI0nWJ0Bp3ZFh4Jx+UlTK0HjdGUjFxY/W WJbB/0Saqk8lzDbMQd+asewoViud59Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633284911; h=from:from:reply-to: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=iH2JsL7W0xFKKIPPGaOXY8EOQcn93ljDlGisHT9c2fU=; b=r3Nv3qg+c+kaifURTfwv4KCKuNOLXnj3PrQPlusz/HxPetTY2kRD3UibonraDd7raGqFjU MHMVBMTxx7H3rVDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F3AC213A09; Sun, 3 Oct 2021 18:15:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id f44ZOi7zWWGtEwAAMHmgww (envelope-from ); Sun, 03 Oct 2021 18:15:10 +0000 From: Nicolai Stange To: Herbert Xu , "David S. Miller" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Stephan=20M=C3=BCller?= , Torsten Duwe , Nicolai Stange Subject: [PATCH 3/8] crypto: api - only support lookups for specific CRYPTO_ALG_TESTED status Date: Sun, 3 Oct 2021 20:14:08 +0200 Message-Id: <20211003181413.12465-4-nstange@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211003181413.12465-1-nstange@suse.de> References: <20211003181413.12465-1-nstange@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Commit ff753308d2f7 ("crypto: api - crypto_alg_mod_lookup either tested or untested") introduced support to crypto_alg_lookup() for ignoring the CRYPTO_ALG_TESTED status in the search. According to the patch description, this had been needed at the time for "constructing givcipher and aead". Callers of crypto_alg_lookup() would enable this behaviour by the special combination of setting CRYPTO_ALG_TESTED in type only, but not in mask. However, the last user invoking this functionality has been gone with commit 3a01d0ee2b99 ("crypto: skcipher - Remove top-level givcipher interface"). With the previous two patches making the userspace facing APIs to validate the mask and type values passed in, the combination of (type & CRYPTO_ALG_TESTED), but !(mask & CRYPTO_ALG_TESTED) is not possible in crypto_alg_lookup() anymore. In preparation for subsequent patches, make this explicit by effectively applying what is a revert of commit ff753308d2f7 ("crypto: api - crypto_alg_mod_lookup either tested or untested") and adding a corresponding WARN_ON_ONCE() to crypto_alg_mod_lookup(). There is no change in behaviour. Note that it is now guaranteed that the first __crypto_alg_lookup() invocation from crypto_alg_mod_lookup() will always have CRYPTO_ALG_TESTED in the mask passed in, which will be needed for a subsequent patch enforcing the same for lookup larvals. Signed-off-by: Nicolai Stange --- crypto/api.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/api.c b/crypto/api.c index ee5991fe11f8..5cced204b6b4 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -239,8 +239,10 @@ static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, struct crypto_alg *alg; u32 test = 0; - if (!((type | mask) & CRYPTO_ALG_TESTED)) + if (!(mask & CRYPTO_ALG_TESTED)) { + WARN_ON_ONCE(type & CRYPTO_ALG_TESTED); test |= CRYPTO_ALG_TESTED; + } down_read(&crypto_alg_sem); alg = __crypto_alg_lookup(name, type | test, mask | test); -- 2.26.2