mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Snowberg <eric.snowberg@oracle.com>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: "open list:SECURITY SUBSYSTEM"
	<linux-security-module@vger.kernel.org>,
	"David Howells" <dhowells@redhat.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Jarkko Sakkinen" <jarkko@kernel.org>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Mimi Zohar" <zohar@linux.ibm.com>,
	"Roberto Sassu" <roberto.sassu@huawei.com>,
	"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>,
	"Mickaël Salaün" <mic@digikod.net>,
	"casey@schaufler-ca.com" <casey@schaufler-ca.com>,
	"Stefan Berger" <stefanb@linux.ibm.com>,
	"ebiggers@kernel.org" <ebiggers@kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>
Subject: Re: [RFC PATCH v2 8/8] clavis: Introduce new LSM called clavis
Date: Tue, 11 Jun 2024 14:36:26 +0000	[thread overview]
Message-ID: <A607E53F-96EF-42BD-A438-FA07C111BEFF@oracle.com> (raw)
In-Reply-To: <754d54b0-5848-4775-a989-43b75dac4dbf@infradead.org>



> On Jun 10, 2024, at 8:33 PM, Randy Dunlap <rdunlap@infradead.org> wrote:
> 
> Hi Eric,
> 
> On 5/30/24 5:39 PM, Eric Snowberg wrote:
>> 
>> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
>> ---
>> Documentation/admin-guide/LSM/clavis.rst | 198 +++++++++++++++++++++++
>> MAINTAINERS                              |   7 +
>> crypto/asymmetric_keys/signature.c       |   4 +
>> include/linux/lsm_hook_defs.h            |   2 +
>> include/linux/security.h                 |   7 +
>> include/uapi/linux/lsm.h                 |   1 +
>> security/Kconfig                         |  10 +-
>> security/clavis/Makefile                 |   1 +
>> security/clavis/clavis.c                 |  25 +++
>> security/clavis/clavis.h                 |   4 +
>> security/clavis/clavis_keyring.c         |  83 ++++++++++
>> security/security.c                      |  16 +-
>> 12 files changed, 352 insertions(+), 6 deletions(-)
>> create mode 100644 Documentation/admin-guide/LSM/clavis.rst
>> create mode 100644 security/clavis/clavis.c
>> 
>> diff --git a/Documentation/admin-guide/LSM/clavis.rst b/Documentation/admin-guide/LSM/clavis.rst
>> new file mode 100644
>> index 000000000000..d1641e3ef38b
>> --- /dev/null
>> +++ b/Documentation/admin-guide/LSM/clavis.rst
>> @@ -0,0 +1,198 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +======
>> +Clavis
>> +======
>> +
>> +Clavis is a Linux Security Module that provides mandatory access control to
>> +system kernel keys (i.e. builtin, secondary, machine and platform). These
>> +restrictions will prohibit keys from being used for validation. Upon boot, the
>> +Clavis LSM is provided a key id as a boot param.  This single key is then
> 
>                                        boot parameter.
> 
>> +used as the root of trust for any access control modifications made going
>> +forward. Access control updates must be signed and validated by this key.
>> +
>> +Clavis has its own keyring.  All ACL updates are applied through this keyring.
>> +The update must be signed by the single root of trust key.
>> +
>> +When enabled, all system keys are prohibited from being used until an ACL is
>> +added for them. There is two exceptions to this rule, builtin keys may be used
> 
>                   There are                       rule:
> 
> 
>> +to validate both signed kernels and modules.
>> +
>> +Adding system kernel keys can only be performed by the machine owner; this
>> +could be through the Machine Owner Key (MOK) or the UEFI Secure Boot DB. It
>> +is possible the machine owner and system administrator may be different
>> +people. The system administrator will not be able to make ACL updates without
>> +them being signed by the machine owner.
>> +
>> +On UEFI platforms, the root of trust key shall survive a kexec. Trying to
>> +defeat or change it from the command line is not allowed.  The original boot
>> +param is stored in UEFI and will always be referenced following a kexec.
> 
>   parameter
> 
>> +
>> +The Clavis LSM contains a system keyring call .clavis.  It contains a single
>> +asymmetric key that is use to validate anything added to it.  This key can only
> 
>                          used
> 
>> +be added during boot and must be a preexisting system kernel key.  If the
>> +``clavis=`` boot param is not used, the keyring does not exist and the feature
> 
>                    parameter
> 
>> +can not be used until the next reboot.
> 
>   cannot
> preferably
> 
>> +
>> +The only user space components are OpenSSL and the keyctl utility. A new
>> +key type call ``clavis_key_acl`` is used for ACL updates. Any number of signed
>> +``clavis_key_acl`` entries may be added to the .clavis keyring. The
>> +``clavis_key_acl`` contains the subject key identifier along with the allowed
>> +usage type for
>> +the key.
> 
> Join 2 lines?
> 
>> +
>> +The format is as follows:
>> +
>> +.. code-block:: console
>> +
>> +  XX:YYYYYYYYYYY
>> +
>> +  XX - Single byte of the key type
>> + VERIFYING_MODULE_SIGNATURE            00
>> + VERIFYING_FIRMWARE_SIGNATURE          01
>> + VERIFYING_KEXEC_PE_SIGNATURE          02
>> + VERIFYING_KEY_SIGNATURE               03
>> + VERIFYING_KEY_SELF_SIGNATURE          04
>> + VERIFYING_UNSPECIFIED_SIGNATURE       05
>> +  :  - ASCII colon
>> +  YY - Even number of hexadecimal characters representing the key id
>> +
>> +The ``clavis_key_acl`` must be S/MIME signed by the sole asymmetric key contained
>> +within the .clavis keyring.
>> +
>> +In the future if new features are added, new key types could be created.
>> +
>> +Usage Examples
>> +==============
>> +
>> +How to create a signing key:
>> +----------------------------
>> +
>> +.. code-block:: bash
>> +
>> +  cat <<EOF > clavis-lsm.genkey
>> +  [ req ]
>> +  default_bits = 4096
>> +  distinguished_name = req_distinguished_name
>> +  prompt = no
>> +  string_mask = utf8only
>> +  x509_extensions = v3_ca
>> +  [ req_distinguished_name ]
>> +  O = TEST
>> +  CN = Clavis LSM key
>> +  emailAddress = user@example.com
>> +  [ v3_ca ]
>> +  basicConstraints=CA:TRUE
>> +  subjectKeyIdentifier=hash
>> +  authorityKeyIdentifier=keyid:always,issuer
>> +  keyUsage=digitalSignature
>> +  EOF
>> +
>> +  openssl req -new -x509 -utf8 -sha256 -days 3650 -batch \
>> +        -config clavis-lsm.genkey -outform DER \
>> +        -out clavis-lsm.x509 -keyout clavis-lsm.priv
>> +
>> +How to get the Subject Key Identifier
>> +-------------------------------------
>> +
>> +.. code-block:: bash
>> +
>> +  openssl x509 -in ./clavis-lsm.x509 -inform der \
>> +        -ext subjectKeyIdentifier  -nocert \
>> +        | tail -n +2 | cut -f2 -d '='| tr -d ':'
>> +  4a00ab9f35c9dc3aed7c225d22bafcbd9285e1e8
>> +
>> +How to enroll the signing key into the MOK
>> +------------------------------------------
>> +
>> +The key must now be added to the machine or platform keyrings.  This
>> +indicates the key was added by the system owner. To add to the machine
>> +keyring on x86 do:
> 
> Are other architectures different? why?

This example would apply to any architecture that boots through a shim and has 
mokutil.  I'll fix this and remove the reference to x86.  I'll also fix all the other changes 
you identified.  Thanks.


  reply	other threads:[~2024-06-11 14:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  0:39 [RFC PATCH v2 0/8] Clavis LSM Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 1/8] certs: Introduce ability to link to a system key Eric Snowberg
2024-06-04 18:08   ` Jarkko Sakkinen
2024-06-05 20:36     ` Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 2/8] clavis: Introduce a new system keyring called clavis Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 3/8] efi: Make clavis boot param persist across kexec Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 4/8] clavis: Prevent clavis boot param from changing during kexec Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 5/8] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE) Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 6/8] keys: Add ability to track intended usage of the public key Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 7/8] clavis: Introduce a new key type called clavis_key_acl Eric Snowberg
2024-05-31  0:39 ` [RFC PATCH v2 8/8] clavis: Introduce new LSM called clavis Eric Snowberg
2024-06-11  2:33   ` Randy Dunlap
2024-06-11 14:36     ` Eric Snowberg [this message]
2024-06-04 17:59 ` [RFC PATCH v2 0/8] Clavis LSM Jarkko Sakkinen
2024-06-05 20:41   ` Eric Snowberg
2024-06-19 15:22 ` Mimi Zohar
2024-06-20 20:18   ` Eric Snowberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A607E53F-96EF-42BD-A438-FA07C111BEFF@oracle.com \
    --to=eric.snowberg@oracle.com \
    --cc=ardb@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=rdunlap@infradead.org \
    --cc=roberto.sassu@huawei.com \
    --cc=serge@hallyn.com \
    --cc=stefanb@linux.ibm.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®