All of lore.kernel.org
 help / color / mirror / Atom feed
From: sudhakar <sudhakar@linux.ibm.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: grub-devel@gnu.org, dja@axtens.net, jan.setjeeilers@oracle.com,
	julian.klode@canonical.com, mate.kukri@canonical.com,
	pjones@redhat.com, avnish@linux.ibm.com, nayna@linux.ibm.com,
	ssrish@linux.ibm.com
Subject: Re: [PATCH v1 12/21] appended signatures: documentation
Date: Wed, 26 Feb 2025 09:58:43 +0530	[thread overview]
Message-ID: <bcb9cff5d0ec768a12773f0b2efd4b86@linux.ibm.com> (raw)
In-Reply-To: <5de51640-4a75-450b-a9dc-be256deb81ff@linux.ibm.com>

On 2024-12-30 21:20, Stefan Berger wrote:
> On 12/18/24 9:56 AM, Sudhakar Kuppusamy wrote:
>> From: Daniel Axtens <dja@axtens.net>
>> 
>> This explains how appended signatures can be used to form part of
>> a secure boot chain, and documents the commands and variables
>> introduced.
>> 
>> Signed-off-by: Daniel Axtens <dja@axtens.net>
>> Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
>> ---
>>   docs/grub.texi | 185 
>> ++++++++++++++++++++++++++++++++++++++++++++-----
>>   1 file changed, 167 insertions(+), 18 deletions(-)
>> 
>> diff --git a/docs/grub.texi b/docs/grub.texi
>> index 6e483298d..f71ce9ffc 100644
>> --- a/docs/grub.texi
>> +++ b/docs/grub.texi
>> @@ -3274,6 +3274,7 @@ These variables have special meaning to GRUB.
>>     @menu
>>   * biosnum::
>> +* check_appended_signatures::
>>   * check_signatures::
>>   * chosen::
>>   * cmdpath::
>> @@ -3336,12 +3337,16 @@ this.
>>   For an alternative approach which also changes BIOS drive mappings 
>> for the
>>   chain-loaded system, @pxref{drivemap}.
>>   +@node check_appended_signatures
>> +@subsection check_appended_signatures
>> +This variable controls whether GRUB enforces appended signature 
>> validation on
>> +certain loaded files. @xref{Using appended signatures}.
>>     @node check_signatures
>>   @subsection check_signatures
>>   -This variable controls whether GRUB enforces digital signature
>> -validation on loaded files. @xref{Using digital signatures}.
>> +This variable controls whether GRUB enforces GPG-style digital 
>> signature
>> +validation on loaded files. @xref{Using GPG-style digital 
>> signatures}.
> 
> I am not sure whether everybody knows what GPG-style digitiabl
> signatures are. Maybe mention here once that those are in a separate
> file.
> 
>>     @node chosen
>>   @subsection chosen
>> @@ -6377,6 +6382,7 @@ you forget a command, you can run the command 
>> @command{help}
>>   * date::                        Display or set current date and time
>>   * devicetree::                  Load a device tree blob
>>   * distrust::                    Remove a pubkey from trusted keys
>> +* distrust_certificate::        Remove a certificate from the list of 
>> trusted certificates
>>   * drivemap::                    Map a drive to another
>>   * echo::                        Display a line of text
>>   * efitextmode::                 Set/Get text output mode resolution
>> @@ -6395,6 +6401,7 @@ you forget a command, you can run the command 
>> @command{help}
>>   * hexdump::                     Show raw contents of a file or 
>> memory
>>   * insmod::                      Insert a module
>>   * keystatus::                   Check key modifier status
>> +* list_certificates::           List trusted certificates
>>   * list_env::                    List variables in environment block
>>   * list_trusted::                List trusted public keys
>>   * load_env::                    Load variables from environment 
>> block
>> @@ -6435,8 +6442,10 @@ you forget a command, you can run the command 
>> @command{help}
>>   * tpm2_key_protector_clear::    Clear the TPM2 key protector
>>   * true::                        Do nothing, successfully
>>   * trust::                       Add public key to list of trusted 
>> keys
>> +* trust_certificate::           Add an x509 certificate to the list 
>> of trusted certificates
>>   * unset::                       Unset an environment variable
>>   @comment * vbeinfo::                     List available video modes
>> +* verify_appended::             Verify appended digital signature
>>   * verify_detached::             Verify detached digital signature
>>   * videoinfo::                   List available video modes
>>   * wrmsr::                       Write values to model-specific 
>> registers
>> @@ -6778,7 +6787,24 @@ These keys are used to validate signatures when 
>> environment variable
>>   @code{check_signatures} is set to @code{enforce}
>>   (@pxref{check_signatures}), and by some invocations of
>>   @command{verify_detached} (@pxref{verify_detached}).  @xref{Using
>> -digital signatures}, for more information.
>> +GPG-style digital signatures}, for more information.
>> +@end deffn
>> +
>> +@node distrust_certificate
>> +@subsection distrust_certificate
>> +
>> +@deffn Command distrust_certificate cert_number
>> +Remove the x509 certificate numbered @var{cert_number} from GRUB's 
>> keyring of
>> +trusted x509 certificates for verifying appended signatures.
>> +
>> +@var{cert_number} is the certificate number as listed by
>> +@command{list_certificates} (@pxref{list_certificates}).
>> +
>> +These certificates are used to validate appended signatures when 
>> environment
>> +variable @code{check_appended_signatures} is set to @code{enforce}
>> +(@pxref{check_appended_signatures}), and by @command{verify_appended}
>> +(@pxref{verify_appended}). See @xref{Using appended signatures} for 
>> more
>> +information.
>>   @end deffn
>>     @node drivemap
>> @@ -7169,6 +7195,19 @@ without any options, the @command{keystatus} 
>> command returns true if and
>>   only if checking key modifier status is supported.
>>   @end deffn
>>   +@node list_certificates
>> +@subsection list_certificates
>> +
>> +@deffn Command list_certificates
>> +List all x509 certificates trusted by GRUB for validating appended 
>> signatures.
>> +The output is a numbered list of certificates, showing the 
>> certificate's serial
>> +number and Common Name.
>> +
>> +The certificate number can be used as an argument to
>> +@command{distrust_certificate} (@pxref{distrust_certificate}).
>> +
>> +See @xref{Using appended signatures} for more information.
>> +@end deffn
>>     @node list_env
>>   @subsection list_env
>> @@ -7189,7 +7228,7 @@ The output is in GPG's v4 key fingerprint format 
>> (i.e., the output of
>>   @code{gpg --fingerprint}).  The least significant four bytes (last
>>   eight hexadecimal digits) can be used as an argument to
>>   @command{distrust} (@pxref{distrust}).
>> -@xref{Using digital signatures}, for more information about uses for
>> +@xref{Using GPG-style digital signatures}, for more information about 
>> uses for
>>   these keys.
>>   @end deffn
>>   @@ -7224,8 +7263,11 @@ When used with care, @option{--skip-sig} and 
>> the whitelist enable an
>>   administrator to configure a system to boot only signed
>>   configurations, but to allow the user to select from among multiple
>>   configurations, and to enable ``one-shot'' boot attempts and
>> -``savedefault'' behavior.  @xref{Using digital signatures}, for more
>> +``savedefault'' behavior.  @xref{Using GPG-style digital signatures}, 
>> for more
>>   information.
>> +Extra care should be taken when combining this command with appended 
>> signatures
>> +(@pxref{Using appended signatures}), as this file is not validated by 
>> an
>> +appended signature and could set @code{check_appended_signatures=no}.
>>   @end deffn
>>     @@ -7596,7 +7638,7 @@ read.  It is possible to modify a digitally 
>> signed environment block
>>   file from within GRUB using this command, such that its signature 
>> will
>>   no longer be valid on subsequent boots.  Care should be taken in 
>> such
>>   advanced configurations to avoid rendering the system
>> -unbootable. @xref{Using digital signatures}, for more information.
>> +unbootable. @xref{Using GPG-style digital signatures}, for more 
>> information.
>>   @end deffn
>>     @@ -8064,11 +8106,30 @@ signatures when environment variable 
>> @code{check_signatures} is set to
>>   must itself be properly signed.  The @option{--skip-sig} option can 
>> be
>>   used to disable signature-checking when reading @var{pubkey_file}
>>   itself. It is expected that @option{--skip-sig} is useful for 
>> testing
>> -and manual booting. @xref{Using digital signatures}, for more
>> +and manual booting. @xref{Using GPG-style digital signatures}, for 
>> more
>>   information.
>>   @end deffn
>>     +@node trust_certificate
>> +@subsection trust_certificate
>> +
>> +@deffn Command trust_certificate x509_certificate
>> +Read a DER-formatted x509 certificate from the file 
>> @var{x509_certificate}
>> +and add it to GRUB's internal list of trusted x509 certificates. 
>> These
>> +certificates are used to validate appended signatures when the 
>> environment
>> +variable @code{check_appended_signatures} is set to @code{enforce}.
>> +
>> +Note that if @code{check_appended_signatures} is set to 
>> @code{enforce}
>> +when @command{trust_certificate} is executed, then 
>> @var{x509_certificate}
>> +must itself bear an appended signature. (It is not sufficient that
>> +@var{x509_certificate} be signed by a trusted certificate according 
>> to the
>> +x509 rules: grub does not include support for validating signatures 
>> within x509
> 
> s/grub/GRUB
> 
>> +certificates themselves.)
>> +
>> +See @xref{Using appended signatures} for more information.
>> +@end deffn
>> +
>>   @node unset
>>   @subsection unset
>>   @@ -8087,6 +8148,18 @@ only on PC BIOS platforms.
>>   @end deffn
>>   @end ignore
>>   +@node verify_appended
>> +@subsection verify_appended
>> +
>> +@deffn Command verify_appended file
>> +Verifies an appended signature on @var{file} against the trusted 
>> certificates
>> +known to GRUB (See @pxref{list_certificates}, 
>> @pxref{trust_certificate}, and
>> +@pxref{distrust_certificate}).
>> +Exit code @code{$?} is set to 0 if the signature validates
>> +successfully.  If validation fails, it is set to a non-zero value.
>> +
>> +See @xref{Using appended signatures}, for more information.
>> +@end deffn
>>     @node verify_detached
>>   @subsection verify_detached
>> @@ -8105,7 +8178,7 @@ tried.
>>     Exit code @code{$?} is set to 0 if the signature validates
>>   successfully.  If validation fails, it is set to a non-zero value.
>> -@xref{Using digital signatures}, for more information.
>> +@xref{Using GPG-style digital signatures}, for more information.
>>   @end deffn
>>     @node videoinfo
>> @@ -8565,14 +8638,15 @@ environment variables and commands are listed 
>> in the same order.
>>   @chapter Security
>>     @menu
>> -* Authentication and authorisation:: Users and access control
>> -* Using digital signatures::         Booting digitally signed code
>> -* UEFI secure boot and shim::        Booting digitally signed PE 
>> files
>> -* Secure Boot Advanced Targeting::   Embedded information for 
>> generation number based revocation
>> -* Measured Boot::                    Measuring boot components
>> -* Lockdown::                         Lockdown when booting on a 
>> secure setup
>> -* TPM2 key protector::               Managing disk key with TPM2 key 
>> protector
>> -* Signing GRUB itself::              Ensuring the integrity of the 
>> GRUB core image
>> +* Authentication and authorisation::   Users and access control
>> +* Using GPG-style digital signatures:: Booting digitally signed code
>> +* Using appended signatures::          An alternative approach to 
>> booting digitally signed code
>> +* UEFI secure boot and shim::          Booting digitally signed PE 
>> files
>> +* Secure Boot Advanced Targeting::     Embedded information for 
>> generation number based revocation
>> +* Measured Boot::                      Measuring boot components
>> +* Lockdown::                           Lockdown when booting on a 
>> secure setup
>> +* TPM2 key protector::                 Managing disk key with TPM2 
>> key protector
>> +* Signing GRUB itself::                Ensuring the integrity of the 
>> GRUB core image
>>   @end menu
>>     @node Authentication and authorisation
>> @@ -8648,8 +8722,8 @@ generating configuration files with 
>> authentication.  You can use
>>   adding @kbd{set superusers=} and @kbd{password} or 
>> @kbd{password_pbkdf2}
>>   commands.
>>   -@node Using digital signatures
>> -@section Using digital signatures in GRUB
>> +@node Using GPG-style digital signatures
>> +@section Using GPG-style digital signatures in GRUB
>>     GRUB's @file{core.img} can optionally provide enforcement that all 
>> files
>>   subsequently read from disk are covered by a valid digital 
>> signature.
>> @@ -8732,6 +8806,81 @@ or BIOS) configuration to cause the machine to 
>> boot from a different
>>   (attacker-controlled) device.  GRUB is at best only one link in a
>>   secure boot chain.
>>   +@node Using appended signatures
>> +@section Using appended signatures in GRUB
>> +
>> +GRUB supports verifying Linux-style 'appended signatures' for secure 
>> boot.
>> +Appended signatures are PKCS#7 messages containing a signature over 
>> the
>> +contents of a file, plus some metadata, appended to the end of a 
>> file. A file
>> +with an appended signature ends with the magic string:
>> +
>> +@example
>> +~Module signature appended~\n
>> +@end example
>> +
>> +where @code{\n} represents the carriage-return character, 
>> @code{0x0a}.
> 
> \n is the newline parameter, \r is carriage-return
> 
>> +
>> +To enable appended signature verification, load the appendedsig 
>> module and an
>> +x509 certificate for verification. Building the appendedsig module 
>> into the
>> +core grub image is recommended.
>> +
>> +Certificates can be managed at boot time using the 
>> @pxref{trust_certificate},
>> +@pxref{distrust_certificate} and @pxref{list_certificates} commands.
>> +Certificates can also be built in to the core image using the 
>> @code{--x509}
>> +parameter to @command{grub-install} or @command{grub-mkimage}.
>> +A file can be explictly verified using the @pxref{verify_appended} 
>> command.
> 
> explicitly
> 
>> +
>> +Only signatures made with the SHA-256 or SHA-512 hash algorithm are 
>> supported,
>> +and only RSA signatures are supported.
>> +
>> +A file can be signed with the @command{sign-file} utility supplied 
>> with the
>> +Linux kernel source. For example, if you have @code{signing.key} as 
>> the private
>> +key and @code{certificate.der} as the x509 certificate containing the 
>> public key:
>> +
>> +@example
>> +sign-file SHA256 signing.key certificate.der vmlinux vmlinux.signed
>> +@end example
>> +
>> +Enforcement of signature verification is controlled by the
>> +@code{check_appended_signatures} variable. Verification will only 
>> take place
>> +when files are loaded if the variable is set to @code{enforce}. If a
>> +certificate is built into the grub core image with the @code{--x509} 
>> parameter,
>> +the variable will be automatically set to @code{enforce} when the 
>> appendedsig
>> +module is loaded.
>> +
>> +Unlike GPG-style signatures, not all files loaded by GRUB are 
>> required to be
>> +signed. Once verification is turned on, the following file types must 
>> carry
>> +appended signatures:
>> +
>> +@enumerate
>> +@item Linux, Multiboot, BSD, XNU and Plan9 kernels
>> +@item Grub modules, except those built in to the core image
>> +@item Any new certificate files to be trusted
>> +@end enumerate
>> +
>> +ACPI tables and Device Tree images will not be checked for appended 
>> signatures
>> +but must be verified by another mechanism such as GPG-style 
>> signatures before
>> +they will be loaded.
>> +
>> +No attempt is made to validate any other file type. In particular,
>> +chain-loaded binaries are not verified - if your platform supports
>> +chain-loading and this cannot be disabled, consider an alternative 
>> secure
>> +boot mechanism.
>> +
>> +As with GPG-style appended signatures, signature checking does 
>> @strong{not}
>> +stop an attacker with console access from dropping manually to the 
>> GRUB
>> +console and executing:
>> +
>> +@example
>> +set check_appended_signatures=no
>> +@end example
>> +
>> +Refer to the section on password-protecting GRUB 
>> (@pxref{Authentication
>> +and authorisation}) for more information on preventing this.
>> +
>> +Additionally, special care must be taken around the @command{loadenv} 
>> command,
>> +which can be used to turn off @code{check_appended_signature}.
>> +
>>   @node UEFI secure boot and shim
>>   @section UEFI secure boot and shim support
>> 
> 
> With nits fixed:
> 
> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>

Thank you Stefan. Fixed it.

Thanks,
Sudhakar Kuppusamy

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

  reply	other threads:[~2025-02-26  4:29 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 14:56 [PATCH v1 00/21] Appended Signature Secure Boot Support for PowerPC Sudhakar Kuppusamy
2024-12-18 14:56 ` [PATCH v1 01/21] powerpc-ieee1275: Add support for signing grub with an appended signature Sudhakar Kuppusamy
2024-12-27 14:58   ` Stefan Berger
2025-02-26  4:24     ` sudhakar
2025-01-04 18:30   ` Vladimir 'phcoder' Serbinenko
2025-01-06  6:25   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 02/21] docs/grub: Document signing grub under UEFI Sudhakar Kuppusamy
2024-12-27 15:00   ` Stefan Berger
2024-12-18 14:56 ` [PATCH v1 03/21] docs/grub: Document signing grub with an appended signature Sudhakar Kuppusamy
2024-12-27 15:04   ` Stefan Berger
2025-01-04 18:32   ` Vladimir 'phcoder' Serbinenko
2025-01-24  9:44   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 04/21] dl: provide a fake grub_dl_set_persistent for the emu target Sudhakar Kuppusamy
2024-12-27 15:06   ` Stefan Berger
2025-01-04 18:36   ` Vladimir 'phcoder' Serbinenko
2025-01-24  9:47   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 05/21] pgp: factor out rsa_pad Sudhakar Kuppusamy
2024-12-27 15:11   ` Stefan Berger
2025-01-04 18:40   ` Vladimir 'phcoder' Serbinenko
2025-02-27 15:26     ` sudhakar
2025-01-24 10:40   ` Avnish Chouhan
2025-02-27 15:28     ` sudhakar
2024-12-18 14:56 ` [PATCH v1 06/21] crypto: move storage for grub_crypto_pk_* to crypto.c Sudhakar Kuppusamy
2024-12-27 15:13   ` Stefan Berger
2025-01-04 18:41   ` Vladimir 'phcoder' Serbinenko
2025-01-24 10:42   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 07/21] grub-install: support embedding x509 certificates Sudhakar Kuppusamy
2024-12-27 16:08   ` Stefan Berger
2025-01-24 10:45   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 08/21] appended signatures: import GNUTLS's ASN.1 description files Sudhakar Kuppusamy
2024-12-28 19:02   ` Stefan Berger
2025-01-24 10:47   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 09/21] appended signatures: parse PKCS#7 signedData and X.509 certificates Sudhakar Kuppusamy
2024-12-28 19:46   ` Stefan Berger
2025-02-26  4:26     ` sudhakar
2025-01-24 11:10   ` Avnish Chouhan
2025-02-27 15:31     ` sudhakar
2025-01-24 11:23   ` Michal Suchánek
2024-12-18 14:56 ` [PATCH v1 10/21] appended signatures: support verifying appended signatures Sudhakar Kuppusamy
2024-12-29 16:37   ` Stefan Berger
2025-02-06  6:10   ` Avnish Chouhan
2025-02-27 15:33     ` sudhakar
2024-12-18 14:56 ` [PATCH v1 11/21] appended signatures: verification tests Sudhakar Kuppusamy
2024-12-30 15:39   ` Stefan Berger
2025-02-14 10:27   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 12/21] appended signatures: documentation Sudhakar Kuppusamy
2024-12-30 15:50   ` Stefan Berger
2025-02-26  4:28     ` sudhakar [this message]
2025-02-14 10:39   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 13/21] ieee1275: enter lockdown based on /ibm,secure-boot Sudhakar Kuppusamy
2024-12-30 22:02   ` Stefan Berger
2025-02-06  6:23   ` Avnish Chouhan
2025-02-27 15:34     ` sudhakar
2024-12-18 14:56 ` [PATCH v1 14/21] ieee1275: Platform Keystore (PKS) Support Sudhakar Kuppusamy
2024-12-30 22:14   ` Stefan Berger
2025-02-26  4:33     ` sudhakar
2025-02-06  9:09   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 15/21] ieee1275: Read the DB and DBX secure boot variables Sudhakar Kuppusamy
2024-12-30 23:01   ` Stefan Berger
2025-02-26  4:43     ` sudhakar
2024-12-30 23:04   ` Stefan Berger
2025-02-26  4:44     ` sudhakar
2025-02-07  5:57   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 16/21] appendedsig: The creation of trusted and distrusted lists Sudhakar Kuppusamy
2024-12-31 17:21   ` Stefan Berger
2025-02-27 15:21     ` sudhakar
2025-02-07  6:39   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 17/21] appendedsig: While verifying the kernel, use " Sudhakar Kuppusamy
2024-12-31 17:37   ` Stefan Berger
2025-02-27 15:22     ` sudhakar
2025-02-07  6:44   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 18/21] ieee1275: set use_static_keys flag Sudhakar Kuppusamy
2025-01-02 13:22   ` Stefan Berger
2025-02-27 15:24     ` sudhakar
2025-02-07  6:46   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 19/21] appendedsig: Reads the default DB keys from ELF Note Sudhakar Kuppusamy
2025-01-02 13:19   ` Stefan Berger
2025-02-27 15:23     ` sudhakar
2025-02-07  6:54   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 20/21] appendedsig: The grub command's trusted and distrusted support Sudhakar Kuppusamy
2025-02-07 10:16   ` Avnish Chouhan
2024-12-18 14:56 ` [PATCH v1 21/21] appendedsig: documentation Sudhakar Kuppusamy
2025-02-07 10:00   ` Avnish Chouhan

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=bcb9cff5d0ec768a12773f0b2efd4b86@linux.ibm.com \
    --to=sudhakar@linux.ibm.com \
    --cc=avnish@linux.ibm.com \
    --cc=dja@axtens.net \
    --cc=grub-devel@gnu.org \
    --cc=jan.setjeeilers@oracle.com \
    --cc=julian.klode@canonical.com \
    --cc=mate.kukri@canonical.com \
    --cc=nayna@linux.ibm.com \
    --cc=pjones@redhat.com \
    --cc=ssrish@linux.ibm.com \
    --cc=stefanb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.