From 9d784831ea8baaf53b70a4fc68f918e999ccde15 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 19 Sep 2012 10:43:43 -0400 Subject: [PATCH 1/4] Don't error on insmod on UEFI/SB, but also don't do any insmodding. - Increase device path size for ieee1275 Resolves: rhbz#857936 - Make network booting work on ieee1275 machines. Resolves: rhbz#857936 --- ...h => grub-2.00-add-fw_path-search_v2.patch | 30 ++++++++++++------- ...the-ieee1275-device-path-buffer-size.patch | 29 ++++++++++++++++++ grub-2.00-no-insmod-on-sb.patch | 8 +++-- grub2.spec | 12 ++++++-- 4 files changed, 64 insertions(+), 15 deletions(-) rename grub-2.00-add-fw_path-search.patch => grub-2.00-add-fw_path-search_v2.patch (66%) create mode 100644 grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch diff --git a/grub-2.00-add-fw_path-search.patch b/grub-2.00-add-fw_path-search_v2.patch similarity index 66% rename from grub-2.00-add-fw_path-search.patch rename to grub-2.00-add-fw_path-search_v2.patch index 367415e..c7857c3 100644 --- a/grub-2.00-add-fw_path-search.patch +++ b/grub-2.00-add-fw_path-search_v2.patch @@ -1,15 +1,20 @@ -From d829d54d0f461c7bc6a7d8bd549cfdacfac51082 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Mon, 21 May 2012 14:36:39 -0400 -Subject: [PATCH] Add fw_path variable +From 40d6b00fa48ae9c1cecf143da5c6061f6ffcb719 Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 19 Sep 2012 21:22:55 -0300 +Subject: [PATCH] Add fw_path variable (revised) +This patch makes grub look for its config file on efi where the app was +found. It was originally written by Matthew Garrett, and adapted to fix the +"No modules are loaded on grub2 network boot" issue: + +https://bugzilla.redhat.com/show_bug.cgi?id=857936 --- grub-core/kern/main.c | 16 ++++++++++++++-- - grub-core/normal/main.c | 20 +++++++++++++++++++- - 2 files changed, 33 insertions(+), 3 deletions(-) + grub-core/normal/main.c | 25 ++++++++++++++++++++++++- + 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 185230c..26481c6 100644 +index 3262444..820fd66 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -114,6 +114,20 @@ grub_set_prefix_and_root (void) @@ -43,10 +48,10 @@ index 185230c..26481c6 100644 if (!device && fwdevice) device = fwdevice; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 1963fe4..64c2a9f 100644 +index 13473ec..39bb734 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -309,7 +309,25 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -333,7 +333,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; @@ -67,6 +72,11 @@ index 1963fe4..64c2a9f 100644 + grub_file_close (file); + grub_enter_normal_mode (config); + } ++ else ++ { ++ /* Ignore all errors. */ ++ grub_errno = 0; ++ } + grub_free (config); + } + } @@ -74,5 +84,5 @@ index 1963fe4..64c2a9f 100644 prefix = grub_env_get ("prefix"); if (prefix) -- -1.7.10.2 +1.7.10.4 diff --git a/grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch b/grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch new file mode 100644 index 0000000..8d254bf --- /dev/null +++ b/grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch @@ -0,0 +1,29 @@ +From 7e1f42417dab20d470d1e45dfa73d00c763d792d Mon Sep 17 00:00:00 2001 +From: Paulo Flabiano Smorigo +Date: Wed, 19 Sep 2012 20:50:38 -0300 +Subject: [PATCH] increase the ieee1275 device path buffer size + +There are cases when the openfirmware device path is bigger then 64 chars. + +This should fix this bugzilla: +https://bugzilla.redhat.com/show_bug.cgi?id=857936 +--- + grub-core/kern/ieee1275/init.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 7d03a8a..5c45947 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -82,7 +82,7 @@ void (*grub_ieee1275_net_config) (const char *dev, + void + grub_machine_get_bootlocation (char **device, char **path) + { +- char bootpath[64]; /* XXX check length */ ++ char bootpath[256]; /* Max device path length */ + char *filename; + char *type; + +-- +1.7.10.4 + diff --git a/grub-2.00-no-insmod-on-sb.patch b/grub-2.00-no-insmod-on-sb.patch index 25719e4..828ce81 100644 --- a/grub-2.00-no-insmod-on-sb.patch +++ b/grub-2.00-no-insmod-on-sb.patch @@ -24,13 +24,15 @@ index eec575c..3df9dbd 100644 /* set ENVVAR=VALUE */ static grub_err_t grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)), -@@ -81,6 +85,11 @@ grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)), +@@ -81,6 +85,13 @@ grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)), { grub_dl_t mod; +#ifdef GRUB_MACHINE_EFI -+ if (grub_efi_secure_boot()) -+ return grub_error (GRUB_ERR_ACCESS_DENIED, N_("Secure Boot forbids insmod")); ++ if (grub_efi_secure_boot()) { ++ //grub_printf("%s\n", N_("Secure Boot forbids insmod")); ++ return 0; ++ } +#endif + if (argc == 0) diff --git a/grub2.spec b/grub2.spec index 54e33e8..758f6c6 100644 --- a/grub2.spec +++ b/grub2.spec @@ -41,7 +41,7 @@ Name: grub2 Epoch: 1 Version: 2.00 -Release: 7%{?dist} +Release: 8%{?dist} Summary: Bootloader with support for Linux, Multiboot and more Group: System Environment/Base @@ -55,7 +55,7 @@ Source5: theme.tar.bz2 #Source6: grub-cd.cfg Patch2: grub-1.99-just-say-linux.patch Patch5: grub-1.99-ppc-terminfo.patch -Patch10: grub-2.00-add-fw_path-search.patch +Patch10: grub-2.00-add-fw_path-search_v2.patch Patch11: grub-2.00-Add-fwsetup.patch Patch13: grub-2.00-Dont-set-boot-on-ppc.patch Patch18: grub-2.00-ignore-gnulib-gets-stupidity.patch @@ -66,6 +66,7 @@ Patch22: grub2-use-linuxefi.patch Patch23: grub-2.00-dont-decrease-mmap-size.patch Patch24: grub-2.00-no-insmod-on-sb.patch Patch25: grub-2.00-efidisk-ahci-workaround.patch +Patch26: grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -418,6 +419,13 @@ fi %doc grub-%{tarversion}/themes/starfield/COPYING.CC-BY-SA-3.0 %changelog +* Thu Sep 20 2012 Peter Jones - 2.00-8 +- Don't error on insmod on UEFI/SB, but also don't do any insmodding. +- Increase device path size for ieee1275 + Resolves: rhbz#857936 +- Make network booting work on ieee1275 machines. + Resolves: rhbz#857936 + * Wed Sep 05 2012 Matthew Garrett - 2.00-7 - Add Apple partition map support for EFI From aec4448a0d8f0fef3757f1aa7bc07fe7bd1c40e5 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 18 Sep 2012 18:02:52 -0400 Subject: [PATCH 2/4] Use grub2-owner@ instead of pjones@ to apply patches. Ninjas all the way down. Signed-off-by: Peter Jones --- grub2.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub2.spec b/grub2.spec index 758f6c6..2463759 100644 --- a/grub2.spec +++ b/grub2.spec @@ -134,7 +134,7 @@ cp %{SOURCE3} . # place unifont in the '.' from which configure is run cp %{SOURCE4} unifont.pcf.gz git init -git config user.email "pjones@fedoraproject.org" +git config user.email "grub2-owner@fedoraproject.org" git config user.name "Fedora Ninjas" git add . git commit -a -q -m "%{tarversion} baseline." @@ -148,7 +148,7 @@ cp %{SOURCE3} . # place unifont in the '.' from which configure is run cp %{SOURCE4} unifont.pcf.gz git init -git config user.email "pjones@fedoraproject.org" +git config user.email "grub2-owner@fedoraproject.org" git config user.name "Fedora Ninjas" git add . git commit -a -q -m "%{tarversion} baseline." From 4ae6c6e738f0cc85b9ee0d51d56927143945c0a6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 25 Sep 2012 16:24:24 -0400 Subject: [PATCH 3/4] sneak in sleep added to the module list --- grub2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub2.spec b/grub2.spec index 2463759..9e3421b 100644 --- a/grub2.spec +++ b/grub2.spec @@ -176,7 +176,7 @@ CD_MODULES=" all_video boot btrfs cat chain configfile echo efifwsetup \ efinet ext2 fat font gfxmenu gfxterm gzio halt hfsplus iso9660 \ jpeg linuxefi minicmd normal part_apple part_msdos part_gpt \ password_pbkdf2 png reboot search search_fs_uuid \ - search_fs_file search_label test video" + search_fs_file search_label sleep test video" ./grub-mkimage -O %{grubefiarch} -o %{grubeficdname}.orig -p /EFI/BOOT \ -d grub-core ${CD_MODULES} %pesign -s -i %{grubeficdname}.orig -o %{grubeficdname} From c8494619a47c97fb009068e58746187e73e96e05 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 1 Oct 2012 13:34:30 -0400 Subject: [PATCH 4/4] Work around bug with using "\x20" in linux command line. Related: rhbz#855849 Signed-off-by: Peter Jones --- grub-2.00-Handle-escapes-in-labels.patch | 187 +++++++++++++++++++++++ grub2.spec | 8 +- 2 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 grub-2.00-Handle-escapes-in-labels.patch diff --git a/grub-2.00-Handle-escapes-in-labels.patch b/grub-2.00-Handle-escapes-in-labels.patch new file mode 100644 index 0000000..0b5f87e --- /dev/null +++ b/grub-2.00-Handle-escapes-in-labels.patch @@ -0,0 +1,187 @@ +From d08e2511db353b2db9c5785d3f22079674abd708 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 1 Oct 2012 13:24:37 -0400 +Subject: [PATCH] Pass "\x[[:hex:]][[:hex:]]" straight through unmolested. + +--- + grub-core/commands/wildcard.c | 16 +++++++++++++++- + grub-core/lib/cmdline.c | 34 +++++++++++++++++++++++++++++++-- + grub-core/script/execute.c | 44 +++++++++++++++++++++++++++++++++++++------ + 3 files changed, 85 insertions(+), 9 deletions(-) + +diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c +index 2b73d9a..d1235dc 100644 +--- a/grub-core/commands/wildcard.c ++++ b/grub-core/commands/wildcard.c +@@ -420,6 +420,12 @@ check_file (const char *dir, const char *basename) + return found; + } + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static void + unescape (char *out, const char *in, const char *end) + { +@@ -428,7 +434,15 @@ unescape (char *out, const char *in, const char *end) + + for (optr = out, iptr = in; iptr < end;) + { +- if (*iptr == '\\' && iptr + 1 < end) ++ if (*iptr == '\\' && iptr + 3 < end && iptr[1] == 'x' && is_hex(iptr[2]) && is_hex(iptr[3])) ++ { ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ *optr++ = *iptr++; ++ continue; ++ } ++ else if (*iptr == '\\' && iptr + 1 < end) + { + *optr++ = iptr[1]; + iptr += 2; +diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c +index a702e64..c8605a7 100644 +--- a/grub-core/lib/cmdline.c ++++ b/grub-core/lib/cmdline.c +@@ -20,6 +20,12 @@ + #include + #include + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static unsigned int check_arg (char *c, int *has_space) + { + int space = 0; +@@ -27,7 +33,13 @@ static unsigned int check_arg (char *c, int *has_space) + + while (*c) + { +- if (*c == '\\' || *c == '\'' || *c == '"') ++ if (*c == '\\' && *(c+1) == 'x' && is_hex(*(c+2)) && is_hex(*(c+3))) ++ { ++ size += 4; ++ c += 4; ++ continue; ++ } ++ else if (*c == '\\' || *c == '\'' || *c == '"') + size++; + else if (*c == ' ') + space = 1; +@@ -82,7 +94,25 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + + while (*c) + { +- if (*c == '\\' || *c == '\'' || *c == '"') ++ if (*c == ' ') ++ { ++ *buf++ = '\\'; ++ *buf++ = 'x'; ++ *buf++ = '2'; ++ *buf++ = '0'; ++ c++; ++ continue; ++ } ++ else if (*c == '\\' && *(c+1) == 'x' && ++ is_hex(*(c+2)) && is_hex(*(c+3))) ++ { ++ *buf++ = *c++; ++ *buf++ = *c++; ++ *buf++ = *c++; ++ *buf++ = *c++; ++ continue; ++ } ++ else if (*c == '\\' || *c == '\'' || *c == '"') + *buf++ = '\\'; + + *buf++ = *c; +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index b5e6eb0..c44eced 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -52,6 +52,12 @@ static struct grub_script_scope *scope = 0; + /* Wildcard translator for GRUB script. */ + struct grub_script_wildcard_translator *grub_wildcard_translator; + ++static int ++is_hex(char c) ++{ ++ return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); ++} ++ + static char* + wildcard_escape (const char *s) + { +@@ -68,7 +74,15 @@ wildcard_escape (const char *s) + i = 0; + while ((ch = *s++)) + { +- if (ch == '*' || ch == '\\' || ch == '?') ++ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) ++ { ++ p[i++] = ch; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ continue; ++ } ++ else if (ch == '*' || ch == '\\' || ch == '?') + p[i++] = '\\'; + p[i++] = ch; + } +@@ -92,7 +106,14 @@ wildcard_unescape (const char *s) + i = 0; + while ((ch = *s++)) + { +- if (ch == '\\') ++ if (ch == '\\' && s[0] == 'x' && is_hex(s[1]) && is_hex(s[2])) ++ { ++ p[i++] = '\\'; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ p[i++] = *s++; ++ } ++ else if (ch == '\\') + p[i++] = *s++; + else + p[i++] = ch; +@@ -381,14 +402,25 @@ parse_string (const char *str, + int escaped = 0; + const char *optr; + ++ grub_printf("str: \"%s\"\n", str); + for (ptr = str; ptr && *ptr; ) + switch (*ptr) + { + case '\\': +- escaped = !escaped; +- if (!escaped && put) +- *((*put)++) = '\\'; +- ptr++; ++ if (!escaped && put && *(ptr+1) == 'x' && is_hex(*(ptr+2)) && is_hex(*(ptr+3))) ++ { ++ *((*put)++) = *ptr++; ++ *((*put)++) = *ptr++; ++ *((*put)++) = *ptr++; ++ *((*put)++) = *ptr++; ++ } ++ else ++ { ++ escaped = !escaped; ++ if (!escaped && put) ++ *((*put)++) = '\\'; ++ ptr++; ++ } + break; + case '$': + if (escaped) +-- +1.7.12.1 + diff --git a/grub2.spec b/grub2.spec index 9e3421b..ce7f515 100644 --- a/grub2.spec +++ b/grub2.spec @@ -41,7 +41,7 @@ Name: grub2 Epoch: 1 Version: 2.00 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Bootloader with support for Linux, Multiboot and more Group: System Environment/Base @@ -67,6 +67,7 @@ Patch23: grub-2.00-dont-decrease-mmap-size.patch Patch24: grub-2.00-no-insmod-on-sb.patch Patch25: grub-2.00-efidisk-ahci-workaround.patch Patch26: grub-2.00-increase-the-ieee1275-device-path-buffer-size.patch +Patch27: grub-2.00-Handle-escapes-in-labels.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -234,6 +235,7 @@ rm -fr $RPM_BUILD_ROOT %ifarch %{efiarchs} cd grub-efi-%{tarversion} make DESTDIR=$RPM_BUILD_ROOT install +find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} \; # Ghost config file install -m 755 -d $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/ @@ -419,6 +421,10 @@ fi %doc grub-%{tarversion}/themes/starfield/COPYING.CC-BY-SA-3.0 %changelog +* Mon Oct 01 2012 Peter Jones - 1:2.00-9 +- Work around bug with using "\x20" in linux command line. + Related: rhbz#855849 + * Thu Sep 20 2012 Peter Jones - 2.00-8 - Don't error on insmod on UEFI/SB, but also don't do any insmodding. - Increase device path size for ieee1275