-
Notifications
You must be signed in to change notification settings - Fork 209
Add Secure Boot Kernel configuration #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
saiarcot895
merged 9 commits into
sonic-net:master
from
davidpil2002:secure_boot_support
Feb 2, 2023
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9e53a97
[secure boot]Add Linux Kernel configuration to support Secure Boot fe…
davidpil2002 9724e9f
[secure boot]Fix few typos
davidpil2002 10322c3
[secure boot]Fix Secure boot build flag condition by adding an extra …
davidpil2002 77e1842
[secure boot]Remove WA after the fix in commit 5717c5d391092f2a8f894e…
davidpil2002 b6003e9
[secure boot]Add secure boot kernel config by using kconfig-secure-bo…
davidpil2002 b6b6c59
[secure boot]removed comment, rename certificate with the name of the…
davidpil2002 46beeb3
[secure boot]Fix equal condition and add input file validation to cer…
davidpil2002 fb8993f
[secure boot]Add signature force flag in kernel config, to force kern…
davidpil2002 9eb7646
Merge branch 'master' into secure_boot_support
saiarcot895 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script is doing modification in kconfig-inclusions and kconfig-exclusions files in order to support Secure Boot feature. | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| $0: # Display Help | ||
| $0 -c <PEM_CERT> -a <CONF_ARCH> | ||
| Script is modifying kernel config file to support system trusted key with custom certificate. | ||
| Note: The signature algorithm used will be RSA over SHA512 x509 format. | ||
|
|
||
| Parameters description: | ||
| PEM_CERT public key (pem format). Key to be store in kernel. | ||
| CONF_ARCH is the kernel arch amd/arm/etc | ||
| Usage example: bash secure_boot_kernel_config.sh cert.pem | ||
| EOF | ||
davidpil2002 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| # the function is appending a line after the string from variable $1 | ||
| # var pos $2: new config to be set | ||
| # var pos $3: filename to be modify | ||
| append_line_after_str() { | ||
| sed -i "/$1/a $2" $3 | ||
| } | ||
|
|
||
| while getopts 'c:a:hv' flag; do | ||
| case "${flag}" in | ||
| c) CERT_PEM="${OPTARG}" ;; | ||
| a) CONF_ARCH="${OPTARG}" ;; | ||
| v) VERBOSE='true' ;; | ||
| h) print_usage | ||
| exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ "$1" = "-h" -o "$1" = "--help" ]; then | ||
| usage | ||
| fi | ||
|
|
||
| [ -f "$CERT_PEM" ] || { | ||
| echo "Error: CERT_PEM file does not exist: $CERT_PEM" | ||
| usage | ||
| exit 1 | ||
| } | ||
|
|
||
| [ ! -z "$CONF_ARCH" ] || { | ||
| echo "Error: CONF_ARCH file does not exist: $CONF_ARCH" | ||
| usage | ||
| exit 1 | ||
| } | ||
|
|
||
| LOCAL_CERT_PEM="debian/certs/$(basename $CERT_PEM)" | ||
| KCONFIG_INCLUSIONS_FILE="../patch/kconfig-inclusions" | ||
| KCONFIG_EXCLUSIONS_FILE="../patch/kconfig-exclusions" | ||
| CONF_ARCH_BLOCK_REGEX="^\[$CONF_ARCH\]" | ||
|
|
||
| echo "$0: Appending kernel configuration in files: $KCONFIG_INCLUSIONS_FILE, $KCONFIG_EXCLUSIONS_FILE" | ||
|
|
||
davidpil2002 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # add support to secure boot and secure warm boot | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_SYSTEM_TRUSTED_KEYS=\"$LOCAL_CERT_PEM\"" $KCONFIG_INCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_MODULE_SIG_HASH=\"sha512\"" $KCONFIG_INCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_MODULE_SIG_SHA512=y" $KCONFIG_INCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_KEXEC_SIG_FORCE=y" $KCONFIG_INCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "#Secure Boot" $KCONFIG_INCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_SECURITY_LOCKDOWN_LSM" $KCONFIG_EXCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_SECURITY_LOCKDOWN_LSM_EARLY" $KCONFIG_EXCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_LOCK_DOWN_KERNEL_FORCE_NONE" $KCONFIG_EXCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT" $KCONFIG_EXCLUSIONS_FILE | ||
| append_line_after_str $CONF_ARCH_BLOCK_REGEX "CONFIG_MODULE_SIG_SHA256" $KCONFIG_EXCLUSIONS_FILE | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.