148 Commits

Author SHA1 Message Date
Archana Polampalli
d218a980af shim: fix CVE-2022-28737
shim: Buffer overflow when loading crafted EFI images.

Reference:
https://nvd.nist.gov/vuln/detail/CVE-2022-2873

Upstream-Status: Backport [e99bdbb827,
159151b664]

CVE: CVE-2022-28737

Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
2023-01-19 11:16:39 +08:00
Xiangyu Chen
551802f96f grub-efi: refresh patches for grub with fix of CVE-2022-28736
CVE-2022-28736 has 3 patches as below was conflicted with some meta-secure-boot layers patches.
loader-efi-chainloader-Simplify-the-loader-state.patch
commands-boot-Add-API-to-pass-context-to-loader.patch
CVE-2022-28736-loader-efi-chainloader-Use-grub_loader_set_ex.patch

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
2023-01-19 11:15:47 +08:00
Mingli Yu
5a8d5924a2 meta-efi-secure-boot: check efi-secure-boot DISTRO_FEATURES
Fix the below yocto compliance issue:
  INFO: ======================================================================
  INFO: FAIL: test_signatures (common.CommonCheckLayer)
  INFO: ----------------------------------------------------------------------
  INFO: Traceback (most recent call last):
   File "/build/layers/oe-core/scripts/lib/checklayer/cases/common.py", line 81, in test_signatures
    self.fail('Adding layer %s changed signatures.\n%s' % (self.tc.layer['name'], msg))
AssertionError: Adding layer meta-efi-secure-boot changed signatures.
17 signatures changed, initial differences (first hash before, second after):
   ovmf-native:do_configure: 98621d634860b524863c76c61a3b48d7aa4080bbe87b02a848ae6574ca349b5e -> 51b7ed0cd68914fe2a74e7db489ee0251fde1feab3ff4826e6df8a8be6f710bc
      bitbake-diffsigs --task ovmf-native do_configure --signature 98621d634860b524863c76c61a3b48d7aa4080bbe87b02a848ae6574ca349b5e 51b7ed0cd68914fe2a74e7db489ee0251fde1feab3ff4826e6df8a8be6f710bc
      NOTE: Starting bitbake server...
      basehash changed from 8b274e0d376c63104cbbcc0004a3758f2673d9e7f959854a0ffaa82ea04a9653 to d53127a75e96264ab92cffc956f93864435d48d1a0bf22899b35f78f1daf3bb3
      Variable PACKAGECONFIG value changed:
      @@ -1,3 +1,3 @@
      - ${@bb.utils.contains('MACHINE_FEATURES', 'tpm', 'tpm', '', d)} ${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)}
      + ${@bb.utils.contains('MACHINE_FEATURES', 'tpm', 'tpm', '', d)} ${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)} secureboot
       MACHINE_FEATURES{tpm} = Unset
       MACHINE_FEATURES{tpm2} = Unset

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
2022-12-06 09:16:14 +08:00
Mingli Yu
39a46d6b15 meta-secure-core: update the README
Fix the below yocto compliance issue:
  INFO: test_readme (common.CommonCheckLayer)
  INFO:  ... FAIL
  INFO: Traceback (most recent call last):
    File "/build/layers/oe-core/scripts/lib/checklayer/cases/common.py", line 34, in test_readme
      self.assertIn('maintainer', data.lower())
    AssertionError: 'maintainer' not found

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
2022-12-06 09:16:14 +08:00
Yi Zhao
fa438247c3 grub-efi: remove build host references from modinfo.sh
Fix buildpaths warning:
WARNING: grub-efi-2.06-r0 do_package_qa: QA Issue: File
/boot/efi/EFI/BOOT/x86_64-efi/modinfo.sh in package grub-efi contains
reference to TMPDIR [buildpaths]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2022-11-03 09:48:02 +08:00
Yi Zhao
225076287f layer.conf: add langdale to LAYERSERIES_COMPAT
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2022-11-03 09:47:47 +08:00
Jia Zhang
2ccf4aa4e3 meta-secure-core: support kirkstone
Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
2022-06-05 14:51:31 +08:00
corey cothrum
b4522579c0 (conditionally) add 'tpm' to list of grub built-in modules
If tpm/tpm2 is enabled in DISTRO features, add the grub 'tpm' module to
GRUB_BUILDIN.

This is now required for secureboot to work w/ TPM is also enabled in a
BIOS.
2022-04-12 08:34:09 +08:00
Yi Zhao
bbd671ca72 meta-secure-core: Handle bitbake variable renaming
This is the result of automated script conversion:
poky/scripts/contrib/convert-variable-renames.py meta-secure-core

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2022-04-08 09:05:06 +08:00
Yi Zhao
56731a69db recipes: Update LICENSE variable to use SPDX license identifiers
Fix QA warnings:
WARNING: efitools-1.9.2+gitAUTOINC+392836a46c-r0 do_package_qa: QA Issue: Recipe LICENSE includes obsolete licenses GPLv2 [obsolete-license]
WARNING: mokutil-0.3.0+gitAUTOINC+e19adc575c-r0 do_package_qa: QA Issue: Recipe LICENSE includes obsolete licenses GPLv3 [obsolete-license]

This is the result of automated script conversion:
poky/scripts/contrib/convert-spdx-licenses.py meta-secure-core

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2022-04-08 09:05:06 +08:00
Hongxu Jia
5d274050c7 grub-efi: split grub serure builtin option from GRUB_BUILDIN
Use variable GRUB_SECURE_BUILDIN to split grub secure
builtin option from GRUB_BUILDIN, then GRUB_BUILDIN will
not contain secure option for others grub-mkimage to
create no secure grub even though secure boot is enabled

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2022-03-15 10:02:19 +08:00
Yi Zhao
2bd48852e2 meta-secure-core: fix wrong operator combination
Operations like XXX:append += "YYY" are almost always wrong and this
is a common mistake made in the metadata. Improve them to use the
standard format.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-11-18 13:58:20 +08:00
Yi Zhao
fea6a37625 recipes: update SRC_URI branch and protocols
Update SRC_URIs using git to include branch=master if no branch is set
and also to use protocol=https for github urls.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-11-15 09:56:02 +08:00
Peter Hatina
5fcb2f0e67 grub-efi: Remove $cmdpath from configuration for for grub-mkimage
Signed-off-by: Peter Hatina <peter@hatina.eu>
2021-10-29 15:37:21 +08:00
Yi Zhao
3fa3fc6dcb efitools: fix openssl.cnf path for openssl 3.0
Fix openssl.cnf path for openssl 3.0 to make sure openssl command can
find it.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-10-21 15:57:54 +08:00
Yi Zhao
9f03a89db8 layer.conf: add honister to LAYERSERIES_COMPAT
Drop other releases since they are not compatible anymore.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-09 18:51:13 +08:00
Yi Zhao
4042043742 meta-secure-core: Convert to new override syntax
Converting the metadata to use ":" as the override character instead of "_".

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-09 18:51:13 +08:00
Mingli Yu
b84dc32e1d shim_git: fix the do_fetch warning
Fixes:
WARNING: shim-12+gitAUTOINC+5202f80c32-r0 do_fetch: Failed to fetch URL git://github.com/rhboot/shim.git, attempting MIRRORS if available

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
2021-07-29 18:44:07 +08:00
jbouchard
b9f183a416 prevent contamining the cache with embeded cfg 2021-05-01 09:29:19 +08:00
Yi Zhao
6cbe3df2a2 layer.conf: add hardknott to LAYERSERIES_COMPAT
Remove other releases since they are not compatible anymore.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-04-21 12:57:22 +08:00
Yi Zhao
bc84821aa4 grub: disable inside lockdown and shim_lock verifiers
The lockdown support[1] and secure boot detection[2] have been added to
grub 2.06. These verifiers are registered when UEFI Secure Boot is
enabled. Unfortunately, they conflict with the current MOK2 Verify
mechanism. So disable them.

Fixes grub error:
error: failed to verify kernel /bzImage

[1] http://git.savannah.gnu.org/cgit/grub.git/commit/?id=578c95298bcc46e0296f4c786db64c2ff26ce2cc
[2] http://git.savannah.gnu.org/cgit/grub.git/commit/?id=d7e54b2e5feee95d2f83058ed30d883c450d1473

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-04-21 12:57:22 +08:00
Kai Kang
f6963bf84b linux-yocto-efi-secure-boot.inc: fix rerun failure
Task do_sign of linux-yocto depends on variable GPG_PATH. When GPG_PATH
changes, it fails to rerun the task:

| Exception: FileExistsError: [Errno 17] File exists:
| 'bzImage-5.2.24-yocto-standard.p7b' -> '/path/to/tmp-glibc/work/intel_x86_64-wrs-linux/linux-yocto/5.2.x+gitAUTOINC+bbe834c1d2_370ab92a1e-r0/image/boot/bzImage.p7b'

Remove the link file before create it if exists already.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
2021-04-21 12:57:22 +08:00
Ovidiu Panait
596c6c76ae grub-efi: enable secure-boot support only for target builds
grub-efi-native does not benefit from the extra code/modules that get built for
secure-boot support, it just increases the build time of the package.
Therefore, mark all secure-boot related procedures in the recipe for
class-target only.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
2021-04-04 22:39:35 +08:00
Alexandru Avadanii
f7ae553e6c grub: Drop useless insmod verify from cfg
- the 'verify' grub module has been renamed to 'pgp' in grub 2.04;
- the 'pgp' grub module is already built-in if GRUB_SIGN_VERIFY is set,
  so there's no need to call insmod;

While at it, remove some unnecessary code duplication.

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2021-03-29 21:01:36 +08:00
Alexandru Avadanii
ab13b08e43 kernel-initramfs: Fix leftover p7b reference
p7b was replaced by the ${SB_FILE_EXT} variable, but one reference
was omitted during the rework.

Fixes: 31d2105b

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2021-03-26 14:13:04 +08:00
Yi Zhao
4e1cc676dc grub-efi: refresh patches for grub 2.06
Rebase patch:
0001-grub-verify-Add-strict_security-variable.patch
Grub-get-and-set-efi-variables.patch
mok2verify-support-to-verify-non-PE-file-with-PKCS-7.patch

Drop 0001-fs-ext2-fix-the-file-not-found-error-when-symlink-fi.patch
since it has been merged upstream.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-24 18:11:20 +08:00
Chen Qi
ee0d07240e grub-efi: update the bbapepnd file name
oe-core now uses the git version for grub-efi, so we'd better to
use the '%' wildcard for the bbappend file name.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2021-03-24 18:11:20 +08:00
Corey Cothrum
1397fdd78f shim: update github address in SRC_URI 2021-03-03 10:56:30 +08:00
Jussi Keranen
64097c52a0 Grub: Verify buffiles, e.g. fonts and images 2021-02-02 18:55:52 +08:00
Jussi Keranen
d72746bfa7 Grub: Parameterize prefix dir 2021-01-22 10:24:34 +08:00
Yi Zhao
d05fc08f90 meta-efi-secure-boot/systemd: switch to meson build
The systemd switched to meson build long time ago. Somehow this bbappend
didn't update. Switch to meson build otherwise these options do not work
at all.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-01-19 17:44:02 +08:00
Yi Zhao
2d1fb96206 grub: fix the file not found error when sysmlink filesize is 60
We encountered a file not found error when the symlink filesize is 60:

$ ls -l initrd
lrwxrwxrwx 1 root root 60 Jan  6 16:37 initrd -> secure-core-image-initramfs-5.10.2-yoctodev-standard.cpio.gz

When booting, we got the following error in grub:
error: file `/initrd' not found

The root cause is although the size of diro->inode.symlink is 60, it
includes the trailing '\0'. So if the symlink filesize is exactly 60, it
is also stored in a separate block rather than in the inode.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-01-19 17:44:02 +08:00
Bartłomiej Burdukiewicz
50a847007d conf/layer.conf: Add gatesgarth to LAYERSERIES_COMPAT
Signed-off-by: Bartłomiej Burdukiewicz <bartlomiej.burdukiewicz@gmail.com>
2020-12-09 09:17:12 +08:00
Yi Zhao
2747958070 grub-efi: refresh patch
Refresh mok2verify-support-to-verify-non-PE-file-with-PKCS-7.patch to
adapt the recent CVEs fixing.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2020-11-10 10:36:25 +08:00
Hongxu Jia
696ee1495c grub-efi-efi-secure-boot.inc: Adapt to potential psuedo changes
If we do adopt path filtering for pseudo, we may filter out ${DEPLOY_DIR}
as not needing to be tracked for "root" permissions. but we do track
the data in ${D} though, when we copy file from ${D} to ${DEPLOY_DIR},
pseudo report a failure
...
|cp: failed to preserve ownership for 'tmp-glibc/work/corei7-64-wrs-linux/
grub-efi/2.04-r0/deploy-grub-efi/efi-unsigned/x86_64-efi/fdt.lst'
: Operation not permitted
...

Disable pseudo for the copy operation

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2020-10-14 19:40:03 +08:00
Christophe Priouzeau
ac1ec689f2 conf/layer.conf: Add dunfell to LAYERSERIES_COMPAT
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@st.com>
2020-05-27 08:22:24 +08:00
Hongxu Jia
8834753407 Revert "Removed unneeded patch to fix compilation error in efi-tool's console.c"
The patch to fix compilation error in efi-tool's console.c is required

This reverts commit a6c3d9fcd2.

In <=gnu-efi-3.0.9 variable is named EFI_WARN_UNKOWN_GLYPH, and
in gnu-efi-3.0.11 is renamed in EFI_WARN_UNKNOWN_GLYPH. The patch is
only for users with installed >=gnu-efi-3.0.11 because is in this
version that variable has changed name from EFI_WARN_UNKOWN_GLYPH
to EFI_WARN_UNKNOWN_GLYPH. [1]

In oe-core master branch, the gnu-efi is 3.0.11, we need to add
the fix back

[1] https://bugs.gentoo.org/701152

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2020-04-16 16:33:23 +08:00
Hongxu Jia
82c404fe33 ovmf_%.bbappend: tweak do_sign task order to avoid racing issue
If ovmf's do_deploy is run before do_sign, there is a failure
...
|install: cannot stat 'tmp-glibc/work/corei7-64-wrs-linux/ovmf/
edk2-stable201911-r0/ovmf/Pkcs7VerifyDxe.efi.signed': No such file or directory
...

Add do_sign before do_deploy

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2020-04-10 16:12:35 +08:00
Abdelrahman Ibrahem
a6c3d9fcd2 Removed unneeded patch to fix compilation error in efi-tool's console.c 2020-04-08 21:52:18 +08:00
richard
d496407fc1 modified grub-efi-efi-secure-boot.inc to install also the grub configuration files in the DEPLOYDIR 2020-03-01 19:27:54 +08:00
Liwei Song
8853e39b1e initramfs: adjust task order to aviod initrd symlink unavailable
adjust task order to make sure initrd symlink is ready before
do package.

Signed-off-by: Liwei Song <liwei.song@windriver.com>
2020-02-27 16:24:34 +08:00
Sandra Tobajas
84ee95f92a linux-yocto: remove unused FILESEXTRAPATHS_prepend
Signed-off-by: Sandra Tobajas <sandra.tobajas@savoirfairelinux.com>
2020-01-16 08:35:40 +08:00
Sandra Tobajas
561800fe3f grub-efi-efi-secure-boot.inc: append do_deploy instead overriding it
Append do_deploy function instead of overriding it.

Signed-off-by: Sandra Tobajas <sandra.tobajas@savoirfairelinux.com>
2020-01-16 08:35:40 +08:00
Sandra Tobajas
44a12b93b1 grub-efi-efi-secure-boot.inc: let EFI_BOOT_PATH be overrided
Let the EFI_BOOT_PATH Bitbake variable be overrided if needed.

Signed-off-by: Sandra Tobajas <sandra.tobajas@savoirfairelinux.com>
2020-01-16 08:35:40 +08:00
Changqing Li
8a518a2054 mokutil: fix typo
Signed-off-by: Changqing Li <changqing.li@windriver.com>
2019-12-30 18:57:07 +08:00
Yi Zhao
c0e7d60718 grub-efi-efi-secure-boot.inc: use task_prepend instead of prefuncs for do_sign
The grub-efi-native build doesn't need to run do_sign task but there are
two prefuncs for do_sign still run in native build. This will cause a
build error when there is no gpg command on the host. Move the functions
to do_sign_prepend_class-target to make sure they only run in target
build.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2019-12-13 18:50:47 +08:00
Hongxu Jia
08c3f81a5f efitools: do not do_sign if GRUB_SIGN_VERIFY not enabled
If GRUB_SIGN_VERIFY is not enabled, do_sign will fail in which GPG_PATH
is not set (--homedir None)
...
|DEBUG: Executing python function do_sign
|NOTE: Running: echo "SecureCore" | tmp-glibc/hosttools/gpg  --pinentry-mode
loopback --batch --homedir None -u "SecureBootCore" --detach-sign
--passphrase-fd 0 "tmp-glibc/work/core2-32-wrs-linux/efitools/
1.9.2+gitAUTOINC+392836a46c-r0/image/boot/efi/EFI/BOOT/LockDown.efi"
|ERROR: Failed to sign: tmp-glibc/work/core2-32-wrs-linux/efitools/
1.9.2+gitAUTOINC+392836a46c-r0/image/boot/efi/EFI/BOOT/LockDown.efi
...

Since GPG_PATH is set in do_sign's prefunc check_boot_public_key if
GRUB_SIGN_VERIFY is enabled, add the same condition to do_sign

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2019-11-19 18:09:03 +08:00
Hongxu Jia
73602a5eea efitools-native: Fix compilation problem with latest /usr/include/efi
Since commit [382ffa1 efitools: Fix compilation problem with
latest /usr/include/efi], we should apply the fix to native also.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2019-11-19 16:05:17 +08:00
Jason Wessel
691252f79f kernel-initramfs-efi-secure-boot.inc: Copy .sig files and .p7b
While refactoring the code to eliminate the overlap in the copy of the
.sig and .p7b files the UEFI_SELOADER test was not removed.  This
results in the .sig files not getting copied to the deploy directory
when using the GRUB_SIGN_VERIFY = "1".

All that is needed is to remove the UEFI_SELOADER test statement.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2019-11-14 08:42:17 +08:00
Jason Wessel
31d2105b7a secure boot: Make SELoader optional and copy sig files when GRUB_SIGN_VERIFY=1
This commit makes the SELoader entire optional and allows it to be
removed, with the intended replacement being to use grub's built in
gpg key verification.

It will be possible in a template or local.conf:

UEFI_SELOADER = "0"
GRUB_SIGN_VERIFY = "1"

[ Issue: LINUXEXEC-2450 ]

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2019-11-08 13:27:23 +08:00