[meta-intel] [PATCH 2/2] systemd-boot: stub: check LoadOptions contains data

Mikko Ylinen mikko.ylinen at linux.intel.com
Tue Feb 28 02:35:12 PST 2017


With some UEFI shells LoadOptionsSize is reported being > 0
but the corresponding LoadOptions does not contain any data
(the first element has value 0).

When that happens, the stub feature that allows .cmdline to be
replaced by what's in LoadOptions ends up copying nothing/random
data to the kernel cmdline resulting in different kinds of boot
problems.

To fix this, add a check to see if LoadOptions contains data
before replacing the .cmdline.

Upstream-Status: Accepted [https://github.com/systemd/systemd/pull/5467]

Fixes [YOCTO #11078].

Signed-off-by: Mikko Ylinen <mikko.ylinen at linux.intel.com>
---
 ...boot-stub-check-LoadOptions-contains-data.patch | 42 ++++++++++++++++++++++
 .../systemd-boot/systemd-boot_%.bbappend           |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch

diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch b/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch
new file mode 100644
index 0000000..69acc8f
--- /dev/null
+++ b/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch
@@ -0,0 +1,42 @@
+From 87cd5a5e0f06ceb7f9dbdcc4029e0c279a38e6ad Mon Sep 17 00:00:00 2001
+From: Mikko Ylinen <mikko.ylinen at linux.intel.com>
+Date: Mon, 27 Feb 2017 10:04:03 +0200
+Subject: [PATCH] sd-boot: stub: check LoadOptions contains data
+
+With some UEFI shells LoadOptionsSize is reported being > 0
+but the corresponding LoadOptions does not contain any data
+(the first element has value 0).
+
+When that happens, the stub feature that allows .cmdline to be
+replaced by what's in LoadOptions ends up copying nothing/random
+data to the kernel cmdline resulting in different kinds of boot
+problems.
+
+To fix this, add a check to see if LoadOptions contains data
+before replacing the .cmdline.
+
+Upstream-Status: Accepted [https://github.com/systemd/systemd/pull/5467]
+
+Fixes [YOCTO #11078].
+
+Signed-off-by: Mikko Ylinen <mikko.ylinen at linux.intel.com>
+---
+ src/boot/efi/stub.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
+index 7c1ffb1bc..b7d5d3cda 100644
+--- a/src/boot/efi/stub.c
++++ b/src/boot/efi/stub.c
+@@ -87,7 +87,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
+         cmdline_len = szs[0];
+ 
+         /* if we are not in secure boot mode, accept a custom command line and replace the built-in one */
+-        if (!secure && loaded_image->LoadOptionsSize > 0) {
++        if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) {
+                 CHAR16 *options;
+                 CHAR8 *line;
+                 UINTN i;
+-- 
+2.11.0
+
diff --git a/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend b/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
index 0db67b1..98eaf45 100644
--- a/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
+++ b/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
@@ -20,6 +20,7 @@ SRC_URI_append_intel-x86-common = " \
             file://0003-sd-boot-Support-global-kernel-command-line-fragment.patch \
             file://0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch \
             file://0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch \
+            file://0001-sd-boot-stub-check-LoadOptions-contains-data.patch \
             "
 
 PACKAGE_ARCH_intel-x86-common = "${INTEL_COMMON_PACKAGE_ARCH}"
-- 
2.11.0



More information about the meta-intel mailing list