From patchwork Tue Jun 21 15:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladis Dronov X-Patchwork-Id: 583691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7D0CC433EF for ; Tue, 21 Jun 2022 15:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350797AbiFUPI6 (ORCPT ); Tue, 21 Jun 2022 11:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352217AbiFUPI5 (ORCPT ); Tue, 21 Jun 2022 11:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DD12BDF35 for ; Tue, 21 Jun 2022 08:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655824136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b5MyrDCt9e6jwWO4uGkHq6tNizdd0TJ4Jm1kcgZbpo0=; b=F9BYfiRXW/Smx5NPyrT4bV8D0poEjP9sZzKVxePqMhffH3Z16bDsgbj4DeeeOtSNjCKMrx qg+H5m0MMvCHzvSgaKN9KcBe8m5d9FKo7ZhMnkl1SNYdMrjQGax1ani/x4I1hN+4RLjMH1 NRR8w14nYtTYmk6y+UfsPxhT48KTNKk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-106-R2Ro1bRQM6CJ-8SPo9_YmQ-1; Tue, 21 Jun 2022 11:08:52 -0400 X-MC-Unique: R2Ro1bRQM6CJ-8SPo9_YmQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A5EC3815D20; Tue, 21 Jun 2022 15:08:52 +0000 (UTC) Received: from rules.brq.redhat.com (unknown [10.40.208.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2DD8C28115; Tue, 21 Jun 2022 15:08:49 +0000 (UTC) From: Vladis Dronov To: Herbert Xu , "David S . Miller" , Randy Dunlap , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladis Dronov , Simo Sorce Subject: [PATCH v2] crypto: fips - make proc files report fips module name and version Date: Tue, 21 Jun 2022 17:08:32 +0200 Message-Id: <20220621150832.1710738-1-vdronov@redhat.com> In-Reply-To: <20220620131618.952133-1-vdronov@redhat.com> References: <20220620131618.952133-1-vdronov@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org FIPS 140-3 introduced a requirement for the FIPS module to return information about itself, specifically a name and a version. These values must match the values reported on FIPS certificates. This patch adds two files to read a name and a version from: /proc/sys/crypto/fips_name /proc/sys/crypto/fips_version v2: removed redundant parentheses in config entries. Signed-off-by: Simo Sorce Signed-off-by: Vladis Dronov --- crypto/Kconfig | 21 +++++++++++++++++++++ crypto/fips.c | 27 ++++++++++++++++++++++----- include/linux/fips.h | 9 +++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/crypto/Kconfig b/crypto/Kconfig index 1d44893a997b..082ff03d9f6c 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -33,6 +33,27 @@ config CRYPTO_FIPS certification. You should say no unless you know what this is. +config CRYPTO_FIPS_NAME + string "FIPS Module Name" + default "Linux Kernel Cryptographic API" + depends on CRYPTO_FIPS + help + This option sets the FIPS Module name reported by the Crypto API via + the /proc/sys/crypto/fips_name file. + +config CRYPTO_FIPS_CUSTOM_VERSION + bool "Use Custom FIPS Module Version" + depends on CRYPTO_FIPS + default n + +config CRYPTO_FIPS_VERSION + string "FIPS Module Version" + default "(none)" + depends on CRYPTO_FIPS_CUSTOM_VERSION + help + This option provides the ability to override the FIPS Module Version. + By default the KERNELRELEASE value is used. + config CRYPTO_ALGAPI tristate select CRYPTO_ALGAPI2 diff --git a/crypto/fips.c b/crypto/fips.c index 7b1d8caee669..644895d23c9b 100644 --- a/crypto/fips.c +++ b/crypto/fips.c @@ -30,13 +30,30 @@ static int fips_enable(char *str) __setup("fips=", fips_enable); +static char fips_name[] = FIPS_MODULE_NAME; +static char fips_version[] = FIPS_MODULE_VERSION; + static struct ctl_table crypto_sysctl_table[] = { { - .procname = "fips_enabled", - .data = &fips_enabled, - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = proc_dointvec + .procname = "fips_enabled", + .data = &fips_enabled, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = proc_dointvec + }, + { + .procname = "fips_name", + .data = &fips_name, + .maxlen = 64, + .mode = 0444, + .proc_handler = proc_dostring + }, + { + .procname = "fips_version", + .data = &fips_version, + .maxlen = 64, + .mode = 0444, + .proc_handler = proc_dostring }, {} }; diff --git a/include/linux/fips.h b/include/linux/fips.h index c6961e932fef..72d2e0e1d3ac 100644 --- a/include/linux/fips.h +++ b/include/linux/fips.h @@ -2,10 +2,19 @@ #ifndef _FIPS_H #define _FIPS_H +#include + #ifdef CONFIG_CRYPTO_FIPS extern int fips_enabled; extern struct atomic_notifier_head fips_fail_notif_chain; +#define FIPS_MODULE_NAME CONFIG_CRYPTO_FIPS_NAME +#ifdef CONFIG_CRYPTO_FIPS_CUSTOM_VERSION +#define FIPS_MODULE_VERSION CONFIG_CRYPTO_FIPS_VERSION +#else +#define FIPS_MODULE_VERSION UTS_RELEASE +#endif + void fips_fail_notify(void); #else