Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1320208imu; Wed, 23 Jan 2019 14:54:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xxirX9L2VhYBK5+X7VHHMOSESlefpCPMSgA0lCgQ3suLf7vgsbWfS477RQDvkRMGTEKf8 X-Received: by 2002:a63:cc4e:: with SMTP id q14mr3670366pgi.291.1548284094658; Wed, 23 Jan 2019 14:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548284094; cv=none; d=google.com; s=arc-20160816; b=BUKVHSeMn2rFpolqu4g4LigC/7HgXbjT27H/2IBcAPY9qN9js5ot2thmXA/SrPmNzv zJo33uh43rZE2j2NPPLYkomtC8PthUdCqFqsj1Q3QbNIxiOVTdHqCfq9qbokPP5CAMPw /yLJ1w6y8Gp0hFOl7+yW4k3lkZajN22xUn7sy1c6b8wR5+/ZyesCFoiJXALb0ynTXwWB CBeyd7GXW2nazeO5ho04CpMbiGPmRO5fYrJzuKOXGKoA4eCEOI7k1t59Nfn7MPlLytg6 NgnsgiuIX50QVcNj9qaCQ6EWlDUeP4d1sZy1pnhq6PWJIT+ioxwyrsEd+3VNZoUDDnuf RhhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3V+nt4lNCHqxoZvcSaq2B4aTARTOckk/B0jHiFraMOk=; b=i4c9nRhkK76yGg5xIpBXwETn4WiauBbONOgpG5XJ3QPSC702SO2UuBg04wOW7vmArb Naw7DpvqZQLuL49ELtvlhcJYOfuyYrspkwLSQUFSEmM1VsDFYBNi7ohjH91sBmwvybWc 5d9fwTMUy37kSWyXLsXcLbFEBZ4AJdNZROiOu236m7phfZlFtiD8C4RogCS+Wg2HGAdZ GN1YzL7mEKWB8prRp1JcCs/1jD7epsBonrJd6gMxMZ+Cb5MHzjSvXklx1I6yWnUP23xc PLhEQeOcI47pLpANKeLzY8cJM6MA/qTJSOzDI4RMR7XCDUcnbyS4FxxsNKeA6DQLu4Dt cKYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MiqCrMXo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z71si20141626pgd.490.2019.01.23.14.54.39; Wed, 23 Jan 2019 14:54:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MiqCrMXo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727383AbfAWWxW (ORCPT + 99 others); Wed, 23 Jan 2019 17:53:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:50142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbfAWWwe (ORCPT ); Wed, 23 Jan 2019 17:52:34 -0500 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9074218AF; Wed, 23 Jan 2019 22:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548283954; bh=C8TKeeMhQf8479EZg15Ln589zEiTSuXOTM+X2AkqBhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MiqCrMXoohQQwKOPyPb7vGRZrk9BYTUlbnLQfftmzuuWv3aWWz2LlJAuxWMfeF6mj WtVosqIdVFZWL91FcSoEXHFpDtFP0ZNDtceNHQeYEzZCLaToFXDJgF3sjNzgCwEkPu zn1Wh0d7WzdBJwOHy8X+yZ586LzIWzcVwXE8Mp2U= From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: linux-kernel@vger.kernel.org, "Jason A . Donenfeld" Subject: [RFC/RFT PATCH 09/15] crypto: testmgr - introduce CONFIG_CRYPTO_MANAGER_EXTRA_TESTS Date: Wed, 23 Jan 2019 14:49:20 -0800 Message-Id: <20190123224926.250525-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog In-Reply-To: <20190123224926.250525-1-ebiggers@kernel.org> References: <20190123224926.250525-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers To achieve more comprehensive crypto test coverage, I'd like to add fuzz tests that use random data layouts and request flags. To be most effective these tests should be part of testmgr, so they automatically run on every algorithm registered with the crypto API. However, they will take much longer to run than the current tests and therefore will only really be intended to be run by developers, whereas the current tests have a wider audience. Therefore, add a new kconfig option CONFIG_CRYPTO_MANAGER_EXTRA_TESTS that can be set by developers to enable these extra, expensive tests. Similar to the regular tests, also add a module parameter cryptomgr.noextratests to support disabling the tests. Finally, another module parameter cryptomgr.fuzz_iterations is added to control how many iterations the fuzz tests do. Note: for now setting this to 0 will be equivalent to cryptomgr.noextratests=1. But I opted for separate parameters to provide more flexibility to add other types of tests under the "extra tests" category in the future. Signed-off-by: Eric Biggers --- crypto/Kconfig | 10 ++++++++++ crypto/testmgr.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/crypto/Kconfig b/crypto/Kconfig index 86960aa53e0f..cbeba16fd8c1 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -168,6 +168,16 @@ config CRYPTO_MANAGER_DISABLE_TESTS Disable run-time self tests that normally take place at algorithm registration. +config CRYPTO_MANAGER_EXTRA_TESTS + bool "Enable extra run-time crypto self tests" + depends on !CRYPTO_MANAGER_DISABLE_TESTS + help + Enable extra run-time self tests of registered crypto algorithms, + including randomized fuzz tests. + + This is intended for developer use only, as these tests take much + longer to run than the normal self tests. + config CRYPTO_GF128MUL tristate "GF(2^128) multiplication functions" help diff --git a/crypto/testmgr.c b/crypto/testmgr.c index a29b42a17841..7c68b4101bd0 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -43,6 +43,16 @@ static bool notests; module_param(notests, bool, 0644); MODULE_PARM_DESC(notests, "disable crypto self-tests"); +#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS +static bool noextratests; +module_param(noextratests, bool, 0644); +MODULE_PARM_DESC(noextratests, "disable expensive crypto self-tests"); + +static unsigned int fuzz_iterations = 100; +module_param(fuzz_iterations, uint, 0644); +MODULE_PARM_DESC(fuzz_iterations, "number of fuzz test iterations"); +#endif + #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS /* a perfect nop */ @@ -4099,6 +4109,10 @@ static void testmgr_onetime_init(void) { alg_check_test_descs_order(); alg_check_testvec_configs(); + +#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS + pr_warn("alg: extra crypto tests enabled. This is intended for developer use only.\n"); +#endif } static int alg_find_test(const char *alg) -- 2.20.1.321.g9e740568ce-goog