Commit Graph

453 Commits

Author SHA1 Message Date
Yi Zhao
62b388cf72 libsign: fix LDFLAGS expansion
When LDFLAGS expands, The -fmacro-prefix-map and -fdebug-prefix-map will
be prefixed with -Wl, which will cause compilation error:
ld: -f may not be used without -shared

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-20 15:59:51 +08:00
Yi Zhao
dad89db9b9 libsign: fix build reproducibility issue
Fixes:
| selsign.c: In function 'show_banner':
| selsign.c:57:62: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
|    57 |         info_cont("Build Time: " __DATE__ " " __TIME__ "\n\n");
|       |                                                              ^
| selsign.c:57:34: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
|    57 |         info_cont("Build Time: " __DATE__ " " __TIME__ "\n\n");
|       |                                  ^~~~~~~~
| cc1: all warnings being treated as errors

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-20 15:59:51 +08:00
Yi Zhao
e004d37650 cryptfs-tpm2: fix LDFLAGS expansion
When LDFLAGS expands, The -fmacro-prefix-map and -fdebug-prefix-map will
be prefixed with -Wl, which will cause compilation error:
ld: -f may not be used without -shared

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-20 15:59:51 +08:00
Yi Zhao
66a1d0582c README: fix typos
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-20 15:59:51 +08:00
Chen Qi
438190a471 layer.conf: add back append to BB_HASHBASE_WHITELIST
Add back the append override, as the '+=' operator will make the
default value of BB_HASHBASE_WHITELIST in oe-core not have any
effect.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2021-08-16 20:39:40 +08:00
Yi Zhao
626750b839 README: update
The image-prelink feature has been disabled by default in oe-core commit
f9719cc1c3fe9d380336e7af418daf27473b2e8b. We don't need to remove it
explicitly in local.conf.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-09 18:51:13 +08:00
Yi Zhao
0e475df858 secure-core-image: pass encrypted password rather than plaintext password to usermod
In oe-core commit 759df7395908f18b3b68f28d043ac9ebd42dd0c8, the
plaintext password setting function was dropped because of the security
issue. So the plaintext password setting method "usermod -P 'password'
user" is not available. Now we should pass the encrypted password to
usermod via -p option.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-08-09 18:51:13 +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
Yi Zhao
6768abc7d4 cryptfs-tpm2: fix build reproducibility issue
Fixes:
| main.c: In function 'show_banner':
| main.c:43:62: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
|    43 |         info_cont("Build Time: " __DATE__ " " __TIME__ "\n\n");
|       |                                                              ^
| main.c:43:34: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
|    43 |         info_cont("Build Time: " __DATE__ " " __TIME__ "\n\n");
|       |                                  ^~~~~~~~
| cc1: all warnings being treated as errors

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
Yi Zhao
c38e155c36 sbsigntool: update PV
The current latest version is 0.9.4 rather than 0.9.2.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-07-07 14:26:51 +08:00
Yi Zhao
31502fb8f2 sbsigntool: fix compile error when enable DEBUG_BUILD
Fixes the following errors when set DEBUG_BUILD = "1":
fileio.c: In function ‘__fileio_read_file’:
fileio.c:179:12: error: ‘len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  179 |   *out_len = len;
      |   ~~~~~~~~~^~~~~
fileio.c:178:12: error: ‘buf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  178 |   *out_buf = buf;
      |   ~~~~~~~~~^~~~~

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-07-07 14:26:51 +08:00
Robert Yang
551137d4eb sbsigntool: Fix for target build
* Remove unnecessary inherit native
This is a target recipe, the "inherit native" is not needed, the
sbsigntool-native is extended by BBCLASSEXTEND which is already present.

Fixed when multilib is enabled:
$ bitbake lib32-sbsigntool
ERROR: Nothing PROVIDES 'lib32-sbsigntool'.

* Add util-linux-libuuid to DEPENDS since it is required by target build

* Add read_write_all.c to common_SOURCES to fix build errors.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
2021-07-07 14:26:51 +08:00
Yi Zhao
0e8603b1ea tpm2-tools: fix CVE-2021-3565
CVE-2021-3565:
A flaw was found in tpm2-tools in versions before 5.1.1 and before
4.3.2. tpm2_import used a fixed AES key for the inner wrapper,
potentially allowing a MITM attacker to unwrap the inner portion and
reveal the key being imported. The highest threat from this
vulnerability is to data confidentiality.

Reference:
https://nvd.nist.gov/vuln/detail/CVE-2021-3565

Patch from:
c069e4f179

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-07-07 14:26:45 +08:00
Yi Zhao
ba04fbba71 create-user-key-store.sh: use grub2-mkpasswd-pbkdf2 rather than grub-mkpasswd-pbkdf2 on RHEL/CentOS/Fedora
On RHEL/CentOS/Fedora, there is no grub-mkpasswd-pbkdf2 command but
grub2-mkpasswd-pbkdf2. Update the script to locate the appropriate
command.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-06-11 15:43:47 +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
Liwei Song
9880c3ab33 Revert "user-key-store.bbclass: Kill gpg agent daemon after gpg sign"
This reverts commit fc8969af8a.

In parallel build this will led sign error because the gpg-agent
in using maybe killed in another task.

Signed-off-by: Liwei Song <liwei.song@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
Mark Hatle
b8040ed6cc meta-signing-key user-key-store.bbclass: don't req tools from efi-secure-boot
If efi-secure-boot distro flag has not been set, then do not require the
sbsigntool, libsign and efitools.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Hongxu Jia <hongxu.jia@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
Yi Zhao
daee77e8d5 sbsigntool: fix compile error when enable DEBUG_BUILD
Fixes the following error when set DEBUG_BUILD = "1":
fileio.c: In function ‘__fileio_read_file’:
fileio.c:179:12: error: ‘len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  179 |   *out_len = len;
      |   ~~~~~~~~~^~~~~
fileio.c:178:12: error: ‘buf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  178 |   *out_buf = buf;
      |   ~~~~~~~~~^~~~~
cc1: all warnings being treated as errors

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-24 18:11:20 +08:00
Joe Slater
f341b8653c sbsigntool: specify TMPDIR
There is a build error if the /tmp directory is mounted with noexec
option:
lib/ccan.git/tools/create-ccan-tree: line 130: /tmp/tmp.MSe2mg2hM5/ccan_depends: Permission denied

Specify a local TMPDIR to fix it.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-24 18:11:20 +08:00
Ilias Apalodimas
a7d57f04b8 sbsigntool: Fix compilation when gnu-efi is missing and re-add patches
commit fa5550d97de6("sbsigntool: Update to latest and change repos")
tried to fix compilation for arm architectures.
Due to the changes in the upstream package though host gnu-efi was
required to compile the package. Also that commit removed a useful
commit (-x support on sbsigntool), which I mistakenly remembered it was
already upstreamed.

So fix the gnu-efi error and fixup the useful patch to keep the
existring functionality.  The old package was also depending on
binutils-dev being installed on the host. Fix that and depend on
binutils-native.
While at it purge the unused patches.

Fixes: commit fa5550d97de6("sbsigntool: Update to latest and change repos")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-03-14 11:52:04 +08:00
Yi Zhao
477e4a812b meta-tpm2/conf/layer.conf: remove meta-python2 from LAYERDEPENDS
Get rid of meta-python2 dependency because python2 is EOL.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-03 14:43:31 +08:00
Yi Zhao
bb0597dddb python-beautifulsoup4: remove recipe
Remove the recipe because no one depends on it anymore.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-03 14:43:31 +08:00
Yi Zhao
1eeb4a31e3 tpm2simulator-native: remove recipe
Remove the recipe because it is unmaintained and its dependency python2
is EOL. Users can use ibmswtpm2 in meta-security as a replacement.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-03-03 14:43:31 +08:00
Corey Cothrum
1397fdd78f shim: update github address in SRC_URI 2021-03-03 10:56:30 +08:00
Ilias Apalodimas
fa5550d97d sbsigntool: Update to latest and change repos
The current sbsigntool repo is ancient and doesn't support native arm
binaries. Let's switch to the current upstream and adjust the recipe
accordingly, allowing the package to be used in native arm machines

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-03-03 10:56:13 +08:00
Hongxu Jia
6009b4d960 mtree: compat glibc 2.33
The glibc 2.33 remove macro _STAT_VER_LINUX [1],
do not use it to represent linux system

[1] https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=sysdeps/unix/sysv/linux/bits/stat.h;h=b5426232088df446f502e6aea76a6cf03e71e1c4;hp=240628a6f4c9028a774c26a04a145c24110f669b;hb=8ed005daf0ab03e142500324a34087ce179ae78e;hpb=428985c436f442e91e27173bccaf28f547233586

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2021-02-09 10:40:10 +08:00
Yi Zhao
032e3b7740 tpm2simulator-native: fix native inheritance order
Classes native/nativesdk must be inherited last to prevent unexpected
behaviour.

Fixes QA warning:
QA Issue: tpm2simulator-native: native/nativesdk class is not inherited
last, this can result in unexpected behaviour. Classes inherited after
native/nativesdk: cmake.bbclass lib_package.bbclass python-dir.bbclass
pythonnative.bbclass [native-last]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-02-04 18:07:53 +08:00
Changqing Li
3704b99169 libsign: fix dependency loop error
fix below error caused by: openssl->libsign-native->openssl
DEBUG:	Dependency loop #1 found:
Dependency loop #1 found:
...

oe-core commits "bitbake.conf/python: Drop setting RDEPENDS/RPROVIDES default"
and "native: Stop clearing PACKAGES" refactor usage of RDEPENDS

Signed-off-by: Changqing Li <changqing.li@windriver.com>
2021-02-04 18:07:22 +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
jussike
f1447e3896 Typo fix: Don't enforce to use RPM 2021-01-14 22:39:03 +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
ca1c4bc784 user-key-store.bbclass: exclude ${GPG_PATH} from pseudo database
Adapt to recent psuedo changes.

Fixes:
ERROR: grub-efi-2.04-r0 do_sign: Failed to import gpg key
gpg: key 9E3086F96EEECC34/9E3086F96EEECC34: error sending to agent: End of file

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2020-12-09 09:16:54 +08:00
Corey Cothrum
8adff592ef create-user-key-store.sh: allow user to specify openssl x509 'days' param
allow openssl x509 '--days' parameter to be specified via command line argument

Signed-off-by: Corey Cothrum <contact@coreycothrum.com>
2020-12-09 09:16:29 +08:00
Yi Zhao
d6ca3fa224 rpm: apply signatures to config files
Since rpm 4.15, the users can control over the installation of
signatures on config files through a variable named
%_ima_sign_config_files. But this is disabled by default. Add a macro
configuration file to enable it.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2020-12-08 22:03:59 +08:00
Yongxin Liu
628949305c meta-encrypted-storage: set CONFIG_HW_RANDOM_TPM to "y"
CONFIG_HW_RANDOM_TPM is bool, not tristate, and thus it cannot be
set to "m"

Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
2020-11-11 15:15:40 +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
Ovidiu Panait
a32ddd2b2a check_gpg_key: Fix gpg-agent.conf creation race condition
If GPG_PATH is already created by signing-keys do_get_public_keys task,
subsequent executions of do_package_write_rpm will not create the
gpg-agent.conf file anymore.

Therefore, the spawned gpg-agent will miss important features such as
auto-expand-secmem, leading to the following intermittent build errors:
....
Subprocess output:
gpg: signing failed: Cannot allocate memory
gpg: signing failed: Cannot allocate memory
error: gpg exec failed (2)
gpg: signing failed: Cannot allocate memory
gpg: signing failed: Cannot allocate memory
error: gpg exec failed (2)
...

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
2020-10-19 19:32:49 +08:00