boot/grub2: Backport 2021/03/02 securify fixes
PATCH 1/1 boot/grub2: Backport 2021/03/02 securify fixes
From: Stefan S?rensen <[email protected]>
Details: https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html
As detailed in commit 7e64a050fbd9add07ed84d48054ffee1b659d079, it is difficult to utilize the upstream patches directly, so a number of patches include changes to generated files so that we don't need invoke the gentpl.py script.
In addition to the security fixes, these required patches has been backported:
f76a27996 efi: Make shim_lock GUID and protocol type public 04ae030d0 efi: Return grub_efi_status_t from grub_efi_get_variable() ac5c93675 efi: Add a function to read EFI variables with attributes d7e54b2e5 efi: Add secure boot detection
The following security issues are fixed:
CVE-2020-14372 grub2: The acpi command allows privileged user to load crafted
ACPI tables when Secure Boot is enabled
CWE-184
7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
GRUB2 enables the use of the command acpi even when Secure Boot is signaled by the firmware. An attacker with local root privileges to can drop a small SSDT in /boot/efi and modify grub.cfg to instruct grub to load said SSDT. The SSDT then gets run by the kernel and it overwrites the kernel lock down configuration enabling the attacker to load unsigned kernel modules and kexec unsigned code.
*******************************************************************************
CVE-2020-25632 grub2: Use-after-free in rmmod command CWE-416 7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
The rmmod implementation for GRUB2 is flawed, allowing an attacker to unload a module used as dependency without checking if any other dependent module is still loaded. This leads to an use-after-free scenario possibly allowing an attacker to execute arbitrary code and by-pass Secure Boot protections.
*******************************************************************************
CVE-2020-25647 grub2: Out-of-bound write in grub_usb_device_initialize() CWE-787
6.9/CVSS:3.1/AV:P/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
grub_usb_device_initialize() is called to handle USB device initialization. It reads out the descriptors it needs from the USB device and uses that data to fill in some USB data structures. grub_usb_device_initialize() performs very little bounds checking and simply assumes the USB device provides sane values. This behavior can trigger memory corruption. If properly exploited, this would lead to arbitrary code execution allowing the attacker to by-pass Secure Boot mechanism.
*******************************************************************************
CVE-2020-27749 grub2: Stack buffer overflow in grub_parser_split_cmdline CWE-121
7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
grub_parser_split_cmdline() expands variable names present in the supplied command line in to their corresponding variable contents and uses a 1kB stack buffer for temporary storage without sufficient bounds checking. If the function is called with a command line that references a variable with a sufficiently large payload, it is possible to overflow the stack buffer, corrupt the stack frame and control execution. An attacker may use this to circumvent Secure Boot protections.
*******************************************************************************
CVE-2020-27779 grub2: The cutmem command allows privileged user to remove
memory regions when Secure Boot is enabled
CWE-285
7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
The GRUB2's cutmem command does not honor Secure Boot locking. This allows an privileged attacker to remove address ranges from memory creating an opportunity to circumvent Secure Boot protections after proper triage about grub's memory layout.
*******************************************************************************
CVE-2021-3418 - grub2: GRUB 2.05 reintroduced CVE-2020-15705 CWE-281 6.4/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H
The GRUB2 upstream reintroduced the CVE-2020-15705. This refers to a distro specific flaw which made upstream in the mentioned version.
If certificates that signed GRUB2 are installed into db, GRUB2 can be booted directly. It will then boot any kernel without signature validation. The booted kernel will think it was booted in Secure Boot mode and will implement lock down, yet it could have been tampered.
This flaw only affects upstream and distributions using the shim_lock verifier.
*******************************************************************************
CVE-2021-20225 grub2: Heap out-of-bounds write in short form option parser CWE-787
7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
The option parser in GRUB2 allows an attacker to write past the end of a heap-allocated buffer by calling certain commands with a large number of specific short forms of options.
*******************************************************************************
CVE-2021-20233 grub2: Heap out-of-bound write due to mis-calculation of
space required for quoting
CWE-787
7.5/CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H
There's a flaw on GRUB2 menu rendering code setparam_prefix() in the menu rendering code performs a length calculation on the assumption that expressing a quoted single quote will require 3 characters, while it actually requires 4 characters. This allow an attacker to corrupt memory by one byte for each quote in the input.
*******************************************************************************
--- ...m_lock-GUID-and-protocol-type-public.patch | 97 + ...efi_status_t-from-grub_efi_get_varia.patch | 149 + ...on-to-read-EFI-variables-with-attrib.patch | 78 + .../0032-efi-Add-secure-boot-detection.patch | 541 + ...s-Move-verifiers-API-to-kernel-image.patch | 1650 ++ ...-shim_lock-verifier-to-the-GRUB-core.patch | 13225 ++++++++++++++++ .../0035-kern-Add-lockdown-support.patch | 763 + ...t-a-variable-if-the-GRUB-is-locked-d.patch | 57 + ...-GRUB-when-the-UEFI-Secure-Boot-is-e.patch | 49 + ...lockdown-instead-of-hardcoding-a-dis.patch | 232 + ...ter-the-acpi-command-when-locked-dow.patch | 76 + ...ter-cutmem-and-badram-commands-when-.patch | 70 + ...t-commands-that-can-load-BIOS-or-DT-.patch | 105 + ...Restrict-setpci-command-when-locked-.patch | 37 + ...Restrict-hdparm-command-when-locked-.patch | 35 + ...Restrict-GDB-access-when-locked-down.patch | 62 + ...-allow-loading-extension-and-package.patch | 61 + ...046-docs-Document-the-cutmem-command.patch | 65 + ...loading-modules-that-are-not-depende.patch | 87 + ...le-out-of-bound-accesses-caused-by-m.patch | 116 + ...leak-when-iterating-over-mapped-memo.patch | 40 + ...ible-dereference-to-of-a-NULL-pointe.patch | 40 + ...net-tftp-Fix-dangling-memory-pointer.patch | 34 + ...n-parser-Fix-resource-leak-if-argc-0.patch | 51 + ...-kern-efi-Fix-memory-leak-on-failure.patch | 31 + ...ix-possible-NULL-pointer-dereference.patch | 66 + ...ulib-regexec-Resolve-unused-variable.patch | 90 + ...mp-Fix-uninitialized-token-structure.patch | 82 + ...-Fix-dereference-of-a-possibly-NULL-.patch | 82 + ...egexec-Fix-possible-null-dereference.patch | 83 + ...b-regcomp-Fix-uninitialized-re_token.patch | 88 + ...e-unnecessary-self-assignment-errors.patch | 42 + ...std-Initialize-seq_t-structure-fully.patch | 35 + ...heck-for-NULL-before-dereferencing-i.patch | 44 + ...re-comp-data-is-freed-before-exiting.patch | 129 + ...-If-failed-then-free-vg-variable-too.patch | 29 + ...ory-leak-on-uninserted-lv-references.patch | 51 + ...odisk-Fix-potential-integer-overflow.patch | 51 + ...that-the-volume-name-length-is-valid.patch | 44 + ...ix-possible-negative-shift-operation.patch | 43 + ...source-leaks-while-constructing-path.patch | 122 + ...0-zfs-Fix-possible-integer-overflows.patch | 57 + ...-a-check-for-error-allocating-memory.patch | 36 + boot/grub2/0072-affs-Fix-memory-leaks.patch | 83 + ...x-possible-unintended-sign-extension.patch | 50 + ...pt-mpi-Fix-possible-NULL-dereference.patch | 49 + ...slinux-Fix-memory-leak-while-parsing.patch | 44 + ...n-Fix-leaking-of-memory-when-process.patch | 53 + ...7-commands-hashsum-Fix-a-memory-leak.patch | 57 + ...move-unnecessary-return-value-of-gru.patch | 95 + ...bfill-Fix-potential-integer-overflow.patch | 79 + ...eo_fb-Fix-multiple-integer-overflows.patch | 105 + ...deo_fb-Fix-possible-integer-overflow.patch | 40 + ...eg-Test-for-an-invalid-next-marker-r.patch | 39 + ...-Remove-code-that-coverity-is-flaggi.patch | 35 + ...ader-bsd-Check-for-NULL-arg-up-front.patch | 48 + .../0086-loader-xnu-Fix-memory-leak.patch | 39 + ...driverkey-data-when-an-error-is-dete.patch | 78 + ...k-if-pointer-is-NULL-before-using-it.patch | 43 + ...nstall-Fix-NULL-pointer-dereferences.patch | 42 + ...v-Fix-incorrect-casting-of-a-signed-.patch | 47 + ...x-incorrect-use-of-a-possibly-negati.patch | 51 + ...ix-NULL-dereference-in-grub_script_e.patch | 29 + ...ire-device_name-is-not-NULL-before-p.patch | 34 + ...void-crash-when-using-outside-a-func.patch | 38 + ...peated-short-options-that-require-an.patch | 56 + ...on-t-crash-on-a-for-loop-with-no-ite.patch | 40 + ...ntry-Fix-quoting-in-setparams_prefix.patch | 48 + ...misc-Always-set-end-in-grub_strtoull.patch | 47 + ...eg-Catch-files-with-unsupported-quan.patch | 53 + ...eg-Catch-OOB-reads-writes-in-grub_jp.patch | 48 + ...eg-Don-t-decode-data-before-start-of.patch | 40 + ...-t-set-up-a-font-with-glyphs-that-ar.patch | 52 + ...impermissibly-large-block-sizes-in-r.patch | 47 + ...-fetch-a-key-beyond-the-end-of-the-n.patch | 33 + ...-use-uninitialized-data-on-corrupt-f.patch | 108 + .../0106-fs-hfs-Disable-under-lockdown.patch | 47 + ...fs-Fix-over-read-of-root-object-name.patch | 50 + ...ve-to-leaf-level-if-name-length-is-n.patch | 34 + ...the-extents-that-getblk-can-consider.patch | 62 + ...0110-fs-jfs-Catch-infinite-recursion.patch | 46 + ...0111-fs-nilfs2-Reject-too-large-keys.patch | 46 + ...search-children-if-provided-number-i.patch | 100 + ...ly-bail-on-errors-in-grub_nilfs2_btr.patch | 68 + ...4-io-gzio-Bail-if-gzio-tl-td-is-NULL.patch | 67 + ..._dynamic_block-clean-up-if-unpacking.patch | 67 + ...issing-values-in-huft_build-and-bail.patch | 57 + ...o-tl-td-in-init_dynamic_block-if-huf.patch | 42 + ...o-beyond-the-end-of-the-data-we-read.patch | 49 + ...last-past-the-end-of-the-circular-me.patch | 43 + ...120-disk-lvm-Bail-on-missing-PV-list.patch | 35 + ...crash-if-an-expected-string-is-not-f.patch | 83 + ...22-disk-lvm-Do-not-overread-metadata.patch | 111 + ...ze-rlocn-offset-to-prevent-wild-read.patch | 41 + ...allow-a-LV-to-be-it-s-own-segment-s-.patch | 39 + ...e-the-number-of-stripes-parities-in-.patch | 33 + ...trfs-Squash-some-uninitialized-reads.patch | 43 + .../0127-kern-parser-Fix-a-memory-leak.patch | 77 + ...parser-Introduce-process_char-helper.patch | 120 + ...arser-Introduce-terminate_arg-helper.patch | 66 + ...ctor-grub_parser_split_cmdline-clean.patch | 92 + ...uffer-Add-variable-sized-heap-buffer.patch | 1237 ++ ...n-parser-Fix-a-stack-buffer-overflow.patch | 248 + ...itial-stack-protector-implementation.patch | 466 + ...emove-unused-code-to-add-BSS-section.patch | 61 + ...-grub_host_to_target32-instead-of-gr.patch | 113 + ...ays-use-grub_host_to_target32-to-ini.patch | 39 + ...fy-more-of-the-PE32-and-PE32-header-.patch | 169 + ...rder-PE-optional-header-fields-set-u.patch | 73 + ...-Improve-data_size-value-calculation.patch | 50 + ...factor-section-setup-to-use-a-helper.patch | 221 + ...-an-option-to-import-SBAT-metadata-i.patch | 264 + ...-grub-install-common-Add-sbat-option.patch | 85 + ...kip-loading-shim_lock-verifier-with-.patch | 270 + ...parse_printf_args-into-format-parsin.patch | 50 + ...RING-type-for-internal-printf-format.patch | 68 + ...nction-to-check-printf-format-agains.patch | 219 + ...k-printf-format-in-the-gui_progress_.patch | 62 + ...tes-Disable-the-os-prober-by-default.patch | 87 + ...-grub_debug_calloc-compilation-error.patch | 33 + boot/grub2/grub2.mk | 8 +- 121 files changed, 26015 insertions(+), 1 deletion(-) create mode 100644 boot/grub2/0029-efi-Make-shim_lock-GUID-and-protocol-type-public.patch create mode 100644 boot/grub2/0030-efi-Return-grub_efi_status_t-from-grub_efi_get_varia.patch create mode 100644 boot/grub2/0031-efi-Add-a-function-to-read-EFI-variables-with-attrib.patch create mode 100644 boot/grub2/0032-efi-Add-secure-boot-detection.patch create mode 100644 boot/grub2/0033-verifiers-Move-verifiers-API-to-kernel-image.patch create mode 100644 boot/grub2/0034-efi-Move-the-shim_lock-verifier-to-the-GRUB-core.patch create mode 100644 boot/grub2/0035-kern-Add-lockdown-support.patch create mode 100644 boot/grub2/0036-kern-lockdown-Set-a-variable-if-the-GRUB-is-locked-d.patch create mode 100644 boot/grub2/0037-efi-Lockdown-the-GRUB-when-the-UEFI-Secure-Boot-is-e.patch create mode 100644 boot/grub2/0038-efi-Use-grub_is_lockdown-instead-of-hardcoding-a-dis.patch create mode 100644 boot/grub2/0039-acpi-Don-t-register-the-acpi-command-when-locked-dow.patch create mode 100644 boot/grub2/0040-mmap-Don-t-register-cutmem-and-badram-commands-when-.patch create mode 100644 boot/grub2/0041-commands-Restrict-commands-that-can-load-BIOS-or-DT-.patch create mode 100644 boot/grub2/0042-commands-setpci-Restrict-setpci-command-when-locked-.patch create mode 100644 boot/grub2/0043-commands-hdparm-Restrict-hdparm-command-when-locked-.patch create mode 100644 boot/grub2/0044-gdb-Restrict-GDB-access-when-locked-down.patch create mode 100644 boot/grub2/0045-loader-xnu-Don-t-allow-loading-extension-and-package.patch create mode 100644 boot/grub2/0046-docs-Document-the-cutmem-command.patch create mode 100644 boot/grub2/0047-dl-Only-allow-unloading-modules-that-are-not-depende.patch create mode 100644 boot/grub2/0048-usb-Avoid-possible-out-of-bound-accesses-caused-by-m.patch create mode 100644 boot/grub2/0049-mmap-Fix-memory-leak-when-iterating-over-mapped-memo.patch create mode 100644 boot/grub2/0050-net-net-Fix-possible-dereference-to-of-a-NULL-pointe.patch create mode 100644 boot/grub2/0051-net-tftp-Fix-dangling-memory-pointer.patch create mode 100644 boot/grub2/0052-kern-parser-Fix-resource-leak-if-argc-0.patch create mode 100644 boot/grub2/0053-kern-efi-Fix-memory-leak-on-failure.patch create mode 100644 boot/grub2/0054-kern-efi-mm-Fix-possible-NULL-pointer-dereference.patch create mode 100644 boot/grub2/0055-gnulib-regexec-Resolve-unused-variable.patch create mode 100644 boot/grub2/0056-gnulib-regcomp-Fix-uninitialized-token-structure.patch create mode 100644 boot/grub2/0057-gnulib-argp-help-Fix-dereference-of-a-possibly-NULL-.patch create mode 100644 boot/grub2/0058-gnulib-regexec-Fix-possible-null-dereference.patch create mode 100644 boot/grub2/0059-gnulib-regcomp-Fix-uninitialized-re_token.patch create mode 100644 boot/grub2/0060-io-lzopio-Resolve-unnecessary-self-assignment-errors.patch create mode 100644 boot/grub2/0061-zstd-Initialize-seq_t-structure-fully.patch create mode 100644 boot/grub2/0062-kern-partition-Check-for-NULL-before-dereferencing-i.patch create mode 100644 boot/grub2/0063-disk-ldm-Make-sure-comp-data-is-freed-before-exiting.patch create mode 100644 boot/grub2/0064-disk-ldm-If-failed-then-free-vg-variable-too.patch create mode 100644 boot/grub2/0065-disk-ldm-Fix-memory-leak-on-uninserted-lv-references.patch create mode 100644 boot/grub2/0066-disk-cryptodisk-Fix-potential-integer-overflow.patch create mode 100644 boot/grub2/0067-hfsplus-Check-that-the-volume-name-length-is-valid.patch create mode 100644 boot/grub2/0068-zfs-Fix-possible-negative-shift-operation.patch create mode 100644 boot/grub2/0069-zfs-Fix-resource-leaks-while-constructing-path.patch create mode 100644 boot/grub2/0070-zfs-Fix-possible-integer-overflows.patch create mode 100644 boot/grub2/0071-zfsinfo-Correct-a-check-for-error-allocating-memory.patch create mode 100644 boot/grub2/0072-affs-Fix-memory-leaks.patch create mode 100644 boot/grub2/0073-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch create mode 100644 boot/grub2/0074-libgcrypt-mpi-Fix-possible-NULL-dereference.patch create mode 100644 boot/grub2/0075-syslinux-Fix-memory-leak-while-parsing.patch create mode 100644 boot/grub2/0076-normal-completion-Fix-leaking-of-memory-when-process.patch create mode 100644 boot/grub2/0077-commands-hashsum-Fix-a-memory-leak.patch create mode 100644 boot/grub2/0079-video-efi_gop-Remove-unnecessary-return-value-of-gru.patch create mode 100644 boot/grub2/0080-video-fb-fbfill-Fix-potential-integer-overflow.patch create mode 100644 boot/grub2/0081-video-fb-video_fb-Fix-multiple-integer-overflows.patch create mode 100644 boot/grub2/0082-video-fb-video_fb-Fix-possible-integer-overflow.patch create mode 100644 boot/grub2/0083-video-readers-jpeg-Test-for-an-invalid-next-marker-r.patch create mode 100644 boot/grub2/0084-gfxmenu-gui_list-Remove-code-that-coverity-is-flaggi.patch create mode 100644 boot/grub2/0085-loader-bsd-Check-for-NULL-arg-up-front.patch create mode 100644 boot/grub2/0086-loader-xnu-Fix-memory-leak.patch create mode 100644 boot/grub2/0087-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch create mode 100644 boot/grub2/0088-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch create mode 100644 boot/grub2/0089-util-grub-install-Fix-NULL-pointer-dereferences.patch create mode 100644 boot/grub2/0090-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch create mode 100644 boot/grub2/0091-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch create mode 100644 boot/grub2/0092-script-execute-Fix-NULL-dereference-in-grub_script_e.patch create mode 100644 boot/grub2/0093-commands-ls-Require-device_name-is-not-NULL-before-p.patch create mode 100644 boot/grub2/0094-script-execute-Avoid-crash-when-using-outside-a-func.patch create mode 100644 boot/grub2/0095-lib-arg-Block-repeated-short-options-that-require-an.patch create mode 100644 boot/grub2/0096-script-execute-Don-t-crash-on-a-for-loop-with-no-ite.patch create mode 100644 boot/grub2/0097-commands-menuentry-Fix-quoting-in-setparams_prefix.patch create mode 100644 boot/grub2/0098-kern-misc-Always-set-end-in-grub_strtoull.patch create mode 100644 boot/grub2/0099-video-readers-jpeg-Catch-files-with-unsupported-quan.patch create mode 100644 boot/grub2/0100-video-readers-jpeg-Catch-OOB-reads-writes-in-grub_jp.patch create mode 100644 boot/grub2/0101-video-readers-jpeg-Don-t-decode-data-before-start-of.patch create mode 100644 boot/grub2/0102-term-gfxterm-Don-t-set-up-a-font-with-glyphs-that-ar.patch create mode 100644 boot/grub2/0103-fs-fshelp-Catch-impermissibly-large-block-sizes-in-r.patch create mode 100644 boot/grub2/0104-fs-hfsplus-Don-t-fetch-a-key-beyond-the-end-of-the-n.patch create mode 100644 boot/grub2/0105-fs-hfsplus-Don-t-use-uninitialized-data-on-corrupt-f.patch create mode 100644 boot/grub2/0106-fs-hfs-Disable-under-lockdown.patch create mode 100644 boot/grub2/0107-fs-sfs-Fix-over-read-of-root-object-name.patch create mode 100644 boot/grub2/0108-fs-jfs-Do-not-move-to-leaf-level-if-name-length-is-n.patch create mode 100644 boot/grub2/0109-fs-jfs-Limit-the-extents-that-getblk-can-consider.patch create mode 100644 boot/grub2/0110-fs-jfs-Catch-infinite-recursion.patch create mode 100644 boot/grub2/0111-fs-nilfs2-Reject-too-large-keys.patch create mode 100644 boot/grub2/0112-fs-nilfs2-Don-t-search-children-if-provided-number-i.patch create mode 100644 boot/grub2/0113-fs-nilfs2-Properly-bail-on-errors-in-grub_nilfs2_btr.patch create mode 100644 boot/grub2/0114-io-gzio-Bail-if-gzio-tl-td-is-NULL.patch create mode 100644 boot/grub2/0115-io-gzio-Add-init_dynamic_block-clean-up-if-unpacking.patch create mode 100644 boot/grub2/0116-io-gzio-Catch-missing-values-in-huft_build-and-bail.patch create mode 100644 boot/grub2/0117-io-gzio-Zero-gzio-tl-td-in-init_dynamic_block-if-huf.patch create mode 100644 boot/grub2/0118-disk-lvm-Don-t-go-beyond-the-end-of-the-data-we-read.patch create mode 100644 boot/grub2/0119-disk-lvm-Don-t-blast-past-the-end-of-the-circular-me.patch create mode 100644 boot/grub2/0120-disk-lvm-Bail-on-missing-PV-list.patch create mode 100644 boot/grub2/0121-disk-lvm-Do-not-crash-if-an-expected-string-is-not-f.patch create mode 100644 boot/grub2/0122-disk-lvm-Do-not-overread-metadata.patch create mode 100644 boot/grub2/0123-disk-lvm-Sanitize-rlocn-offset-to-prevent-wild-read.patch create mode 100644 boot/grub2/0124-disk-lvm-Do-not-allow-a-LV-to-be-it-s-own-segment-s-.patch create mode 100644 boot/grub2/0125-fs-btrfs-Validate-the-number-of-stripes-parities-in-.patch create mode 100644 boot/grub2/0126-fs-btrfs-Squash-some-uninitialized-reads.patch create mode 100644 boot/grub2/0127-kern-parser-Fix-a-memory-leak.patch create mode 100644 boot/grub2/0128-kern-parser-Introduce-process_char-helper.patch create mode 100644 boot/grub2/0129-kern-parser-Introduce-terminate_arg-helper.patch create mode 100644 boot/grub2/0130-kern-parser-Refactor-grub_parser_split_cmdline-clean.patch create mode 100644 boot/grub2/0131-kern-buffer-Add-variable-sized-heap-buffer.patch create mode 100644 boot/grub2/0132-kern-parser-Fix-a-stack-buffer-overflow.patch create mode 100644 boot/grub2/0133-kern-efi-Add-initial-stack-protector-implementation.patch create mode 100644 boot/grub2/0134-util-mkimage-Remove-unused-code-to-add-BSS-section.patch create mode 100644 boot/grub2/0135-util-mkimage-Use-grub_host_to_target32-instead-of-gr.patch create mode 100644 boot/grub2/0136-util-mkimage-Always-use-grub_host_to_target32-to-ini.patch create mode 100644 boot/grub2/0137-util-mkimage-Unify-more-of-the-PE32-and-PE32-header-.patch create mode 100644 boot/grub2/0138-util-mkimage-Reorder-PE-optional-header-fields-set-u.patch create mode 100644 boot/grub2/0139-util-mkimage-Improve-data_size-value-calculation.patch create mode 100644 boot/grub2/0140-util-mkimage-Refactor-section-setup-to-use-a-helper.patch create mode 100644 boot/grub2/0141-util-mkimage-Add-an-option-to-import-SBAT-metadata-i.patch create mode 100644 boot/grub2/0142-grub-install-common-Add-sbat-option.patch create mode 100644 boot/grub2/0143-shim_lock-Only-skip-loading-shim_lock-verifier-with-.patch create mode 100644 boot/grub2/0144-kern-misc-Split-parse_printf_args-into-format-parsin.patch create mode 100644 boot/grub2/0145-kern-misc-Add-STRING-type-for-internal-printf-format.patch create mode 100644 boot/grub2/0146-kern-misc-Add-function-to-check-printf-format-agains.patch create mode 100644 boot/grub2/0147-gfxmenu-gui-Check-printf-format-in-the-gui_progress_.patch create mode 100644 boot/grub2/0148-templates-Disable-the-os-prober-by-default.patch create mode 100644 boot/grub2/0149-kern-mm-Fix-grub_debug_calloc-compilation-error.patch
boot/grub2/0029-efi-Make-shim_lock-GUID-and-protocol-type-public.patch new file +97 -0
@@ -0,0 +1,97 @@ +From f76a27996c34900f2c369a8a0d6ac72ae2faa988 Mon Sep 17 00:00:00 2001 +From: Daniel Kiper <[email protected]> +Date: Thu, 3 Dec 2020 16:01:45 +0100 +Subject: [PATCH] efi: Make shim_lock GUID and protocol type public + +The GUID will be used to properly detect and report UEFI Secure Boot +status to the x86 Linux kernel. The functionality will be added by +subsequent patches. The shim_lock protocol type is made public for +completeness. + +Additionally, fix formatting of four preceding GUIDs. + +Signed-off-by: Daniel Kiper <[email protected]> +Signed-off-by: Marco A Benatto <[email protected]> +Signed-off-by: Javier Martinez Canillas <[email protected]> +Reviewed-by: Daniel Kiper <[email protected]> +Signed-off-by: Stefan S?rensen <[email protected]> +--- + grub-core/commands/efi/shim_lock.c | 12 ------------ + include/grub/efi/api.h | 19 +++++++++++++++---- + 2 files changed, 15 insertions(+), 16 deletions(-) + +diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c +index 764098c..d8f52d7 100644 +--- a/grub-core/commands/efi/shim_lock.c ++++ b/grub-core/commands/efi/shim_lock.c +@@ -27,18 +27,6 @@ + + GRUB_MOD_LICENSE ("GPLv3+"); + +-#define GRUB_EFI_SHIM_LOCK_GUID \ +- { 0x605dab50, 0xe046, 0x4300, \ +- { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \ +- } +- +-struct grub_efi_shim_lock_protocol +-{ +- grub_efi_status_t +- (*verify) (void *buffer, grub_uint32_t size); +-}; +-typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t; +- + static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID; + static grub_efi_shim_lock_protocol_t *sl; + +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index cf1355a..13e5715 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -316,22 +316,27 @@ + + #define GRUB_EFI_SAL_TABLE_GUID \ + { 0xeb9d2d32, 0x2d88, 0x11d3, \ +- { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ ++ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + + #define GRUB_EFI_HCDP_TABLE_GUID \ + { 0xf951938d, 0x620b, 0x42ef, \ +- { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \ ++ { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \ + } + + #define GRUB_EFI_DEVICE_TREE_GUID \ + { 0xb1b621d5, 0xf19c, 0x41a5, \ +- { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \ ++ { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \ + } + + #define GRUB_EFI_VENDOR_APPLE_GUID \ + { 0x2B0585EB, 0xD8B8, 0x49A9, \ +- { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \ ++ { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \ ++ } ++ ++#define GRUB_EFI_SHIM_LOCK_GUID \ ++ { 0x605dab50, 0xe046, 0x4300, \ ++ { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \ + } + + struct grub_efi_sal_system_table +@@ -1689,6 +1694,12 @@ struct grub_efi_block_io + }; + typedef struct grub_efi_block_io grub_efi_block_io_t; + ++struct grub_efi_shim_lock_protocol ++{ ++ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size); ++}; ++typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t; ++ + #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ + || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ + || defined(__riscv) +-- +2.14.2 +
boot/grub2/0030-efi-Return-grub_efi_status_t-from-grub_efi_get_varia.patch new file +149 -0
149 lines not on this page · raw message
boot/grub2/0031-efi-Add-a-function-to-read-EFI-variables-with-attrib.patch new file +78 -0
78 lines not on this page · raw message
boot/grub2/0032-efi-Add-secure-boot-detection.patch new file +541 -0
541 lines not on this page · raw message
boot/grub2/0033-verifiers-Move-verifiers-API-to-kernel-image.patch new file +1650 -0
1,650 lines not on this page · raw message
boot/grub2/0034-efi-Move-the-shim_lock-verifier-to-the-GRUB-core.patch new file +13225 -0
485 lines not on this page · raw message
boot/grub2/0035-kern-Add-lockdown-support.patch new file +763 -0
763 lines not on this page · raw message
boot/grub2/0036-kern-lockdown-Set-a-variable-if-the-GRUB-is-locked-d.patch new file +57 -0
57 lines not on this page · raw message
boot/grub2/0037-efi-Lockdown-the-GRUB-when-the-UEFI-Secure-Boot-is-e.patch new file +49 -0
49 lines not on this page · raw message
boot/grub2/0038-efi-Use-grub_is_lockdown-instead-of-hardcoding-a-dis.patch new file +232 -0
232 lines not on this page · raw message
boot/grub2/0039-acpi-Don-t-register-the-acpi-command-when-locked-dow.patch new file +76 -0
76 lines not on this page · raw message
boot/grub2/0040-mmap-Don-t-register-cutmem-and-badram-commands-when-.patch new file +50 -0
50 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
+ GRUB_MOD_INIT(mmap)
+ {
+- cmd = grub_register_command ("badram", grub_cmd_badram,
+- N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
+- N_("Declare memory regions as faulty (badram)."));
+- cmd_cut = grub_register_command ("cutmem", grub_cmd_cutmem,
+- N_("FROM[K|M|G] TO[K|M|G]"),
+- N_("Remove any memory regions in specified range."));
++ cmd = grub_register_command_lockdown ("badram", grub_cmd_badram,
++ N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
++ N_("Declare memory regions as faulty (badram)."));
++ cmd_cut = grub_register_command_lockdown ("cutmem", grub_cmd_cutmem,
++ N_("FROM[K|M|G] TO[K|M|G]"),
++ N_("Remove any memory regions in specified range."));+
+ }
+
+--
+2.14.2
+
boot/grub2/0041-commands-Restrict-commands-that-can-load-BIOS-or-DT-.patch new file +105 -0
105 lines not on this page · raw message
boot/grub2/0042-commands-setpci-Restrict-setpci-command-when-locked-.patch new file +37 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0043-commands-hdparm-Restrict-hdparm-command-when-locked-.patch new file +35 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0044-gdb-Restrict-GDB-access-when-locked-down.patch new file +62 -0
62 lines not on this page · raw message
boot/grub2/0045-loader-xnu-Don-t-allow-loading-extension-and-package.patch new file +61 -0
61 lines not on this page · raw message
boot/grub2/0046-docs-Document-the-cutmem-command.patch new file +65 -0
65 lines not on this page · raw message
boot/grub2/0047-dl-Only-allow-unloading-modules-that-are-not-depende.patch new file +87 -0
87 lines not on this page · raw message
boot/grub2/0048-usb-Avoid-possible-out-of-bound-accesses-caused-by-m.patch new file +116 -0
116 lines not on this page · raw message
boot/grub2/0049-mmap-Fix-memory-leak-when-iterating-over-mapped-memo.patch new file +40 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0050-net-net-Fix-possible-dereference-to-of-a-NULL-pointe.patch new file +40 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0051-net-tftp-Fix-dangling-memory-pointer.patch new file +34 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0052-kern-parser-Fix-resource-leak-if-argc-0.patch new file +51 -0
51 lines not on this page · raw message
boot/grub2/0053-kern-efi-Fix-memory-leak-on-failure.patch new file +31 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0054-kern-efi-mm-Fix-possible-NULL-pointer-dereference.patch new file +66 -0
66 lines not on this page · raw message
boot/grub2/0055-gnulib-regexec-Resolve-unused-variable.patch new file +90 -0
90 lines not on this page · raw message
boot/grub2/0056-gnulib-regcomp-Fix-uninitialized-token-structure.patch new file +82 -0
82 lines not on this page · raw message
boot/grub2/0057-gnulib-argp-help-Fix-dereference-of-a-possibly-NULL-.patch new file +82 -0
82 lines not on this page · raw message
boot/grub2/0058-gnulib-regexec-Fix-possible-null-dereference.patch new file +83 -0
83 lines not on this page · raw message
boot/grub2/0059-gnulib-regcomp-Fix-uninitialized-re_token.patch new file +88 -0
88 lines not on this page · raw message
boot/grub2/0060-io-lzopio-Resolve-unnecessary-self-assignment-errors.patch new file +42 -0
42 lines not on this page · raw message
boot/grub2/0061-zstd-Initialize-seq_t-structure-fully.patch new file +35 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0062-kern-partition-Check-for-NULL-before-dereferencing-i.patch new file +44 -0
44 lines not on this page · raw message
boot/grub2/0063-disk-ldm-Make-sure-comp-data-is-freed-before-exiting.patch new file +129 -0
129 lines not on this page · raw message
boot/grub2/0064-disk-ldm-If-failed-then-free-vg-variable-too.patch new file +29 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0065-disk-ldm-Fix-memory-leak-on-uninserted-lv-references.patch new file +51 -0
51 lines not on this page · raw message
boot/grub2/0066-disk-cryptodisk-Fix-potential-integer-overflow.patch new file +51 -0
51 lines not on this page · raw message
boot/grub2/0067-hfsplus-Check-that-the-volume-name-length-is-valid.patch new file +44 -0
44 lines not on this page · raw message
boot/grub2/0068-zfs-Fix-possible-negative-shift-operation.patch new file +43 -0
43 lines not on this page · raw message
boot/grub2/0069-zfs-Fix-resource-leaks-while-constructing-path.patch new file +122 -0
122 lines not on this page · raw message
boot/grub2/0070-zfs-Fix-possible-integer-overflows.patch new file +57 -0
57 lines not on this page · raw message
boot/grub2/0071-zfsinfo-Correct-a-check-for-error-allocating-memory.patch new file +36 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0072-affs-Fix-memory-leaks.patch new file +83 -0
83 lines not on this page · raw message
boot/grub2/0073-libgcrypt-mpi-Fix-possible-unintended-sign-extension.patch new file +50 -0
50 lines not on this page · raw message
boot/grub2/0074-libgcrypt-mpi-Fix-possible-NULL-dereference.patch new file +49 -0
49 lines not on this page · raw message
boot/grub2/0075-syslinux-Fix-memory-leak-while-parsing.patch new file +44 -0
44 lines not on this page · raw message
boot/grub2/0076-normal-completion-Fix-leaking-of-memory-when-process.patch new file +53 -0
53 lines not on this page · raw message
boot/grub2/0077-commands-hashsum-Fix-a-memory-leak.patch new file +57 -0
57 lines not on this page · raw message
boot/grub2/0079-video-efi_gop-Remove-unnecessary-return-value-of-gru.patch new file +95 -0
95 lines not on this page · raw message
boot/grub2/0080-video-fb-fbfill-Fix-potential-integer-overflow.patch new file +79 -0
79 lines not on this page · raw message
boot/grub2/0081-video-fb-video_fb-Fix-multiple-integer-overflows.patch new file +105 -0
105 lines not on this page · raw message
boot/grub2/0082-video-fb-video_fb-Fix-possible-integer-overflow.patch new file +40 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0083-video-readers-jpeg-Test-for-an-invalid-next-marker-r.patch new file +39 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0084-gfxmenu-gui_list-Remove-code-that-coverity-is-flaggi.patch new file +35 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0085-loader-bsd-Check-for-NULL-arg-up-front.patch new file +48 -0
48 lines not on this page · raw message
boot/grub2/0086-loader-xnu-Fix-memory-leak.patch new file +39 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0087-loader-xnu-Free-driverkey-data-when-an-error-is-dete.patch new file +78 -0
78 lines not on this page · raw message
boot/grub2/0088-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch new file +43 -0
43 lines not on this page · raw message
boot/grub2/0089-util-grub-install-Fix-NULL-pointer-dereferences.patch new file +42 -0
42 lines not on this page · raw message
boot/grub2/0090-util-grub-editenv-Fix-incorrect-casting-of-a-signed-.patch new file +47 -0
47 lines not on this page · raw message
boot/grub2/0091-util-glue-efi-Fix-incorrect-use-of-a-possibly-negati.patch new file +51 -0
51 lines not on this page · raw message
boot/grub2/0092-script-execute-Fix-NULL-dereference-in-grub_script_e.patch new file +29 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0093-commands-ls-Require-device_name-is-not-NULL-before-p.patch new file +34 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0094-script-execute-Avoid-crash-when-using-outside-a-func.patch new file +38 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0095-lib-arg-Block-repeated-short-options-that-require-an.patch new file +56 -0
56 lines not on this page · raw message
boot/grub2/0096-script-execute-Don-t-crash-on-a-for-loop-with-no-ite.patch new file +40 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0097-commands-menuentry-Fix-quoting-in-setparams_prefix.patch new file +48 -0
48 lines not on this page · raw message
boot/grub2/0098-kern-misc-Always-set-end-in-grub_strtoull.patch new file +47 -0
47 lines not on this page · raw message
boot/grub2/0099-video-readers-jpeg-Catch-files-with-unsupported-quan.patch new file +53 -0
53 lines not on this page · raw message
boot/grub2/0100-video-readers-jpeg-Catch-OOB-reads-writes-in-grub_jp.patch new file +48 -0
48 lines not on this page · raw message
boot/grub2/0101-video-readers-jpeg-Don-t-decode-data-before-start-of.patch new file +40 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0102-term-gfxterm-Don-t-set-up-a-font-with-glyphs-that-ar.patch new file +52 -0
52 lines not on this page · raw message
boot/grub2/0103-fs-fshelp-Catch-impermissibly-large-block-sizes-in-r.patch new file +47 -0
47 lines not on this page · raw message
boot/grub2/0104-fs-hfsplus-Don-t-fetch-a-key-beyond-the-end-of-the-n.patch new file +33 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0105-fs-hfsplus-Don-t-use-uninitialized-data-on-corrupt-f.patch new file +108 -0
108 lines not on this page · raw message
boot/grub2/0106-fs-hfs-Disable-under-lockdown.patch new file +47 -0
47 lines not on this page · raw message
boot/grub2/0107-fs-sfs-Fix-over-read-of-root-object-name.patch new file +50 -0
50 lines not on this page · raw message
boot/grub2/0108-fs-jfs-Do-not-move-to-leaf-level-if-name-length-is-n.patch new file +34 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0109-fs-jfs-Limit-the-extents-that-getblk-can-consider.patch new file +62 -0
62 lines not on this page · raw message
boot/grub2/0110-fs-jfs-Catch-infinite-recursion.patch new file +46 -0
46 lines not on this page · raw message
boot/grub2/0111-fs-nilfs2-Reject-too-large-keys.patch new file +46 -0
46 lines not on this page · raw message
boot/grub2/0112-fs-nilfs2-Don-t-search-children-if-provided-number-i.patch new file +100 -0
100 lines not on this page · raw message
boot/grub2/0113-fs-nilfs2-Properly-bail-on-errors-in-grub_nilfs2_btr.patch new file +68 -0
68 lines not on this page · raw message
boot/grub2/0114-io-gzio-Bail-if-gzio-tl-td-is-NULL.patch new file +67 -0
67 lines not on this page · raw message
boot/grub2/0115-io-gzio-Add-init_dynamic_block-clean-up-if-unpacking.patch new file +67 -0
67 lines not on this page · raw message
boot/grub2/0116-io-gzio-Catch-missing-values-in-huft_build-and-bail.patch new file +57 -0
57 lines not on this page · raw message
boot/grub2/0117-io-gzio-Zero-gzio-tl-td-in-init_dynamic_block-if-huf.patch new file +42 -0
42 lines not on this page · raw message
boot/grub2/0118-disk-lvm-Don-t-go-beyond-the-end-of-the-data-we-read.patch new file +49 -0
49 lines not on this page · raw message
boot/grub2/0119-disk-lvm-Don-t-blast-past-the-end-of-the-circular-me.patch new file +43 -0
43 lines not on this page · raw message
boot/grub2/0120-disk-lvm-Bail-on-missing-PV-list.patch new file +35 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0121-disk-lvm-Do-not-crash-if-an-expected-string-is-not-f.patch new file +83 -0
83 lines not on this page · raw message
boot/grub2/0122-disk-lvm-Do-not-overread-metadata.patch new file +111 -0
111 lines not on this page · raw message
boot/grub2/0123-disk-lvm-Sanitize-rlocn-offset-to-prevent-wild-read.patch new file +41 -0
41 lines not on this page · raw message
boot/grub2/0124-disk-lvm-Do-not-allow-a-LV-to-be-it-s-own-segment-s-.patch new file +39 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0125-fs-btrfs-Validate-the-number-of-stripes-parities-in-.patch new file +33 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0126-fs-btrfs-Squash-some-uninitialized-reads.patch new file +43 -0
43 lines not on this page · raw message
boot/grub2/0127-kern-parser-Fix-a-memory-leak.patch new file +77 -0
77 lines not on this page · raw message
boot/grub2/0128-kern-parser-Introduce-process_char-helper.patch new file +120 -0
120 lines not on this page · raw message
boot/grub2/0129-kern-parser-Introduce-terminate_arg-helper.patch new file +66 -0
66 lines not on this page · raw message
boot/grub2/0130-kern-parser-Refactor-grub_parser_split_cmdline-clean.patch new file +92 -0
92 lines not on this page · raw message
boot/grub2/0131-kern-buffer-Add-variable-sized-heap-buffer.patch new file +1237 -0
1,237 lines not on this page · raw message
boot/grub2/0132-kern-parser-Fix-a-stack-buffer-overflow.patch new file +248 -0
248 lines not on this page · raw message
boot/grub2/0133-kern-efi-Add-initial-stack-protector-implementation.patch new file +34 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
+-dnl Check if the C compiler supports `-fstack-protector'.
++dnl Check if the C compiler supports the stack protector
+ AC_DEFUN([grub_CHECK_STACK_PROTECTOR],[
+-[# Smashing stack protector.
++[# Stack smashing protector.
+ ssp_possible=yes]
+ AC_MSG_CHECKING([whether $CC' accepts -fstack-protector'])
+ # Is this a reliable test case?
+@@ -324,6 +324,40 @@ else
+ ssp_possible=no]
+ AC_MSG_RESULT([no])
+ [fi]
++[# Strong stack smashing protector.
++ssp_strong_possible=yes]
++AC_MSG_CHECKING([whether $CC' accepts -fstack-protector-strong']) ++# Is this a reliable test case?
++AC_LANG_CONFTEST([AC_LANG_SOURCE([[
++void foo (void) { volatile char a[8]; a[3]; }
++]])])
++[# $CC -c -o ...' might not be portable. But, oh, well... Is calling ++# ac_compile' like this correct, after all?
++if eval "$ac_compile -S -fstack-protector-strong -o conftest.s" 2> /dev/null; then]
++ AC_MSG_RESULT([yes]) ++ [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? ++ rm -f conftest.s
++else
++ ssp_strong_possible=no]
++ AC_MSG_RESULT([no])
++[fi]
++[# Global stack smashing protector.
++ssp_global_possible=yes]
++AC_MSG_CHECKING([whether $CC' accepts -mstack-protector-guard=global'])
++# Is this a reliable test case?
++AC_LANG_CONFTEST([AC_LANG_SOURCE([[
++void foo (void) { volatile char a[8]; a[3]; }
++]])])
++[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
++# `ac_compile' like this correct, after all?
++if eval "$ac_compile -S -fstack-protector -mstack-protector-guard=global -o conftest.s" 2> /dev/null; then]
++ AC_MSG_RESULT([yes]) ++ [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? ++ rm -f conftest.s
++else
++ ssp_global_possible=no]
++ AC_MSG_RESULT([no])
++[fi]
+ ])
+
+ dnl Check if the C compiler supports `-mstack-arg-probe' (Cygwin). +diff --git a/configure b/configure
+index 9290ae8..973f702 100755
+--- a/configure
++++ b/configure
+@@ -1778,6 +1778,7 @@ with_libintl_prefix
+ with_libpth_prefix
+ with_included_regex
+ enable_efiemu
++enable_stack_protector
+ enable_mm_debug
+ enable_cache_stats
+ enable_boot_time
+@@ -2459,6 +2460,8 @@ Optional Features:
+ --disable-rpath do not hardcode runtime library paths + --enable-efiemu build and install the efiemu runtimes + (default=guessed) ++ --enable-stack-protector ++ enable the stack protector + --enable-mm-debug include memory manager debugging + --enable-cache-stats enable disk cache statistics collection + --enable-boot-time enable boot time statistics collection
+@@ -32348,9 +32351,9 @@ fi
+
+ CFLAGS="$TARGET_CFLAGS"
+
+-# Smashing stack protector.
++# Stack smashing protector.
+
+-# Smashing stack protector.
++# Stack smashing protector.
+ ssp_possible=yes
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \$CC' accepts \-fstack-protector'" >&5
+ $as_echo_n "checking whether \$CC' accepts \-fstack-protector'... " >&6; }
+@@ -32373,11 +32376,88 @@ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+ fi
++# Strong stack smashing protector.
++ssp_strong_possible=yes
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \$CC' accepts \-fstack-protector-strong'" >&5 ++$as_echo_n "checking whether \$CC' accepts \-fstack-protector-strong'... " >&6; }
++# Is this a reliable test case?
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
+
+-# Need that, because some distributions ship compilers that include +-# `-fstack-protector' in the default specs. +-if test "x$ssp_possible" = xyes; then +- TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
++void foo (void) { volatile char a[8]; a[3]; }
++
++_ACEOF
++# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
++# `ac_compile' like this correct, after all?
++if eval "$ac_compile -S -fstack-protector-strong -o conftest.s" 2> /dev/null; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ # Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
++ rm -f conftest.s
++else
++ ssp_strong_possible=no
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++# Global stack smashing protector.
++ssp_global_possible=yes
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \$CC' accepts \-mstack-protector-guard=global'" >&5 ++$as_echo_n "checking whether \$CC' accepts \-mstack-protector-guard=global'... " >&6; }
++# Is this a reliable test case?
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++void foo (void) { volatile char a[8]; a[3]; }
++
++_ACEOF
++# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
++# `ac_compile' like this correct, after all?
++if eval "$ac_compile -S -fstack-protector -mstack-protector-guard=global -o conftest.s" 2> /dev/null; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ # Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
++ rm -f conftest.s
++else
++ ssp_global_possible=no
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++# Check whether --enable-stack-protector was given.
++if test "${enable_stack_protector+set}" = set; then :
++ enableval=$enable_stack_protector;
++else
++ enable_stack_protector=no
++fi
++
++if test "x$enable_stack_protector" = xno; then
++ if test "x$ssp_possible" = xyes; then
++ # Need that, because some distributions ship compilers that include ++ # `-fstack-protector' in the default specs. ++ TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
++ fi
++elif test "x$platform" != xefi; then
++ as_fn_error $? "--enable-stack-protector is only supported on EFI platforms" "$LINENO" 5
++elif test "x$ssp_global_possible" != xyes; then
++ as_fn_error $? "--enable-stack-protector is not supported (compiler doesn't support -mstack-protector-guard=global)" "$LINENO" 5 ++else
++ TARGET_CFLAGS="$TARGET_CFLAGS -mstack-protector-guard=global"
++ if test "x$enable_stack_protector" = xyes; then
++ if test "x$ssp_possible" != xyes; then
++ as_fn_error $? "--enable-stack-protector is not supported (compiler doesn't support -fstack-protector)" "$LINENO" 5
++ fi
++ TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector"
++ elif test "x$enable_stack_protector" = xstrong; then
++ if test "x$ssp_strong_possible" != xyes; then
++ as_fn_error $? "--enable-stack-protector=strong is not supported (compiler doesn't support -fstack-protector-strong)" "$LINENO" 5
++ fi
++ TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector-strong"
++ else
++ # Note, -fstack-protector-all requires that the protector is disabled for ++ # functions that appear in the call stack when the canary is initialized. ++ as_fn_error $? "invalid value $enable_stack_protector for --enable-stack-protector" "$LINENO" 5
++ fi
++ TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DGRUB_STACK_PROTECTOR=1"
+ fi
+
+ CFLAGS="$TARGET_CFLAGS"
+@@ -37054,5 +37134,10 @@ echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excus
+ else
+ echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
+ fi
++if test "x$enable_stack_protector" != xno; then
++echo "With stack smashing protector: Yes"
++else
++echo "With stack smashing protector: No"
++fi
+ echo "*******************************************************"
+
+diff --git a/configure.ac b/configure.ac
+index 7656f24..bb6b02a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1285,12 +1285,41 @@ fi]
+
+ CFLAGS="$TARGET_CFLAGS"
+
+-# Smashing stack protector.
++# Stack smashing protector.
+ grub_CHECK_STACK_PROTECTOR
+-# Need that, because some distributions ship compilers that include +-# `-fstack-protector' in the default specs. +-if test "x$ssp_possible" = xyes; then +- TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
++AC_ARG_ENABLE([stack-protector],
++ AS_HELP_STRING([--enable-stack-protector],
++ [enable the stack protector]),
++ [],
++ [enable_stack_protector=no])
++if test "x$enable_stack_protector" = xno; then
++ if test "x$ssp_possible" = xyes; then
++ # Need that, because some distributions ship compilers that include ++ # `-fstack-protector' in the default specs. ++ TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
++ fi
++elif test "x$platform" != xefi; then
++ AC_MSG_ERROR([--enable-stack-protector is only supported on EFI platforms])
++elif test "x$ssp_global_possible" != xyes; then
++ AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -mstack-protector-guard=global)]) ++else
++ TARGET_CFLAGS="$TARGET_CFLAGS -mstack-protector-guard=global"
++ if test "x$enable_stack_protector" = xyes; then
++ if test "x$ssp_possible" != xyes; then
++ AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -fstack-protector)])
++ fi
++ TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector"
++ elif test "x$enable_stack_protector" = xstrong; then
++ if test "x$ssp_strong_possible" != xyes; then
++ AC_MSG_ERROR([--enable-stack-protector=strong is not supported (compiler doesn't support -fstack-protector-strong)])
++ fi
++ TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector-strong"
++ else
++ # Note, -fstack-protector-all requires that the protector is disabled for ++ # functions that appear in the call stack when the canary is initialized. ++ AC_MSG_ERROR([invalid value $enable_stack_protector for --enable-stack-protector])
++ fi
++ TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DGRUB_STACK_PROTECTOR=1"
+ fi
+
+ CFLAGS="$TARGET_CFLAGS"
+@@ -2103,5 +2132,10 @@ echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excus
+ else
+ echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
+ fi
++if test "x$enable_stack_protector" != xno; then
++echo "With stack smashing protector: Yes"
++else
++echo "With stack smashing protector: No"
++fi
+ echo "*******************************************************"
+ ]
+diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
+index 30e23ad..ee88e44 100644
+--- a/grub-core/Makefile.am
++++ b/grub-core/Makefile.am
+@@ -90,6 +90,7 @@ endif
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/stack_protector.h
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
+ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/verify.h
+diff --git a/grub-core/Makefile.in b/grub-core/Makefile.in
+index 1f8133b..50c70b5 100644
+--- a/grub-core/Makefile.in
++++ b/grub-core/Makefile.in
+@@ -16425,6 +16425,7 @@ KERNEL_HEADER_FILES = $(top_srcdir)/include/grub/cache.h \
+ $(am__append_5795) $(top_srcdir)/include/grub/mm.h \
+ $(top_srcdir)/include/grub/parser.h \
+ $(top_srcdir)/include/grub/partition.h \
++ $(top_srcdir)/include/grub/stack_protector.h \
+ $(top_srcdir)/include/grub/term.h \
+ $(top_srcdir)/include/grub/time.h \
+ $(top_srcdir)/include/grub/verify.h \
+diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
+index 1333465..7facacf 100644
+--- a/grub-core/kern/efi/init.c
++++ b/grub-core/kern/efi/init.c
+@@ -27,6 +27,58 @@
+ #include <grub/env.h>
+ #include <grub/mm.h>
+ #include <grub/kernel.h>
++#include <grub/stack_protector.h>
++
++#ifdef GRUB_STACK_PROTECTOR
++
++static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID;
++
++/*
++ * Don't put this on grub_efi_init()'s local stack to avoid it
++ * getting a stack check.
++ */
++static grub_efi_uint8_t stack_chk_guard_buf[32];
++
++grub_addr_t __stack_chk_guard;
++
++void __attribute__ ((noreturn))
++__stack_chk_fail (void)
++{
++ /*
++ * Assume it's not safe to call into EFI Boot Services. Sorry, that ++ * means no console message here. ++ */
++ do
++ {
++ /* Do not optimize out the loop. */
++ asm volatile ("");
++ }
++ while (1);
++}
++
++static void
++stack_protector_init (void)
++{
++ grub_efi_rng_protocol_t *rng;
++
++ /* Set up the stack canary. Make errors here non-fatal for now. */
++ rng = grub_efi_locate_protocol (&rng_protocol_guid, NULL);
++ if (rng != NULL)
++ {
++ grub_efi_status_t status;
++
++ status = efi_call_4 (rng->get_rng, rng, NULL, sizeof (stack_chk_guard_buf),
++ stack_chk_guard_buf);
++ if (status == GRUB_EFI_SUCCESS)++ grub_memcpy (&__stack_chk_guard, stack_chk_guard_buf, sizeof (__stack_chk_guard));
++ }
++}
++#else
++static void
++stack_protector_init (void)
++{
++}
++#endif
+
+ grub_addr_t grub_modbase;
+
+@@ -38,6 +90,8 @@ grub_efi_init (void)
+ messages. */
+ grub_console_init ();
+
++ stack_protector_init ();
++
+ /* Initialize the memory management system. */
+ grub_efi_mm_init ();
+
+diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index 13e5715..5517f7e 100644
+--- a/include/grub/efi/api.h
++++ b/include/grub/efi/api.h
+@@ -339,6 +339,11 @@
+ { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \
+ }
+
++#define GRUB_EFI_RNG_PROTOCOL_GUID \
++ { 0x3152bca5, 0xeade, 0x433d, \
++ { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
++ }
++
+ struct grub_efi_sal_system_table
+ {
+ grub_uint32_t signature;
+@@ -1700,6 +1705,20 @@ struct grub_efi_shim_lock_protocol
+ };
+ typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t; +
++typedef grub_efi_guid_t grub_efi_rng_algorithm_t;
++
++struct grub_efi_rng_protocol
++{
++ grub_efi_status_t (*get_info) (struct grub_efi_rng_protocol *this,
++ grub_efi_uintn_t *rng_algorithm_list_size,
++ grub_efi_rng_algorithm_t *rng_algorithm_list);
++ grub_efi_status_t (*get_rng) (struct grub_efi_rng_protocol *this,
++ grub_efi_rng_algorithm_t *rng_algorithm,
++ grub_efi_uintn_t rng_value_length,
++ grub_efi_uint8_t *rng_value);
++};
++typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t; ++
+ #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
+ || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ + || defined(__riscv)
+diff --git a/include/grub/stack_protector.h b/include/grub/stack_protector.h +new file mode 100644
+index 0000000..c88dc00
+--- /dev/null
++++ b/include/grub/stack_protector.h
+@@ -0,0 +1,30 @@
++/*
++ * GRUB -- GRand Unified Bootloader
++ * Copyright (C) 2021 Free Software Foundation, Inc.
++ *
++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef GRUB_STACK_PROTECTOR_H
++#define GRUB_STACK_PROTECTOR_H 1
++
++#include <grub/symbol.h>
++#include <grub/types.h>
++
++#ifdef GRUB_STACK_PROTECTOR
++extern grub_addr_t EXPORT_VAR (__stack_chk_guard);
++extern void __attribute__ ((noreturn)) EXPORT_FUNC (__stack_chk_fail) (void); ++#endif
++
++#endif /* GRUB_STACK_PROTECTOR_H */
+diff --git a/po/POTFILES.in b/po/POTFILES.in
+index 7753ab4..ef42c7d 100644
+--- a/po/POTFILES.in
++++ b/po/POTFILES.in
+@@ -1319,6 +1319,7 @@
+ ./include/grub/sparc64/time.h
+ ./include/grub/sparc64/types.h
+ ./include/grub/speaker.h++./include/grub/stack_protector.h
+ ./include/grub/symbol.h
+ ./include/grub/syslinux_parse.h
+ ./include/grub/term.h
+--
+2.14.2
+
boot/grub2/0134-util-mkimage-Remove-unused-code-to-add-BSS-section.patch new file +61 -0
61 lines not on this page · raw message
boot/grub2/0135-util-mkimage-Use-grub_host_to_target32-instead-of-gr.patch new file +113 -0
113 lines not on this page · raw message
boot/grub2/0136-util-mkimage-Always-use-grub_host_to_target32-to-ini.patch new file +39 -0
Lines of this file are not shown. View the raw message.
boot/grub2/0137-util-mkimage-Unify-more-of-the-PE32-and-PE32-header-.patch new file +169 -0
169 lines not on this page · raw message
boot/grub2/0138-util-mkimage-Reorder-PE-optional-header-fields-set-u.patch new file +73 -0
73 lines not on this page · raw message
boot/grub2/0139-util-mkimage-Improve-data_size-value-calculation.patch new file +50 -0
50 lines not on this page · raw message
boot/grub2/0140-util-mkimage-Refactor-section-setup-to-use-a-helper.patch new file +221 -0
221 lines not on this page · raw message
boot/grub2/0141-util-mkimage-Add-an-option-to-import-SBAT-metadata-i.patch new file +264 -0
264 lines not on this page · raw message
boot/grub2/0142-grub-install-common-Add-sbat-option.patch new file +85 -0
85 lines not on this page · raw message
boot/grub2/0143-shim_lock-Only-skip-loading-shim_lock-verifier-with-.patch new file +270 -0
270 lines not on this page · raw message
boot/grub2/0144-kern-misc-Split-parse_printf_args-into-format-parsin.patch new file +50 -0
50 lines not on this page · raw message
boot/grub2/0145-kern-misc-Add-STRING-type-for-internal-printf-format.patch new file +68 -0
68 lines not on this page · raw message
boot/grub2/0146-kern-misc-Add-function-to-check-printf-format-agains.patch new file +219 -0
219 lines not on this page · raw message
boot/grub2/0147-gfxmenu-gui-Check-printf-format-in-the-gui_progress_.patch new file +62 -0
62 lines not on this page · raw message
boot/grub2/0148-templates-Disable-the-os-prober-by-default.patch new file +87 -0
87 lines not on this page · raw message
boot/grub2/0149-kern-mm-Fix-grub_debug_calloc-compilation-error.patch new file +33 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.29.2
Part of the diff is not shown here. View the raw message.
Yann E. MORIN
AppliedPATCH 1/1 boot/grub2: Backport 2021/03/02 securify fixes
Stefan, All,
On 2021-03-11 10:53 +0100, stefan at astylos.dk spake thusly:
Quoted 3 lines
From: Stefan S?rensen <[email protected]>
Details: https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html
[--SNIP--]
That was quite a hell of a patch...
Applied to master, thanks.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 boot/grub2: Backport 2021/03/02 securify fixes
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Stefan, All,
On 2021-03-11 10:53 +0100, stefan at astylos.dk spake thusly:Quoted 3 lines
From: Stefan S?rensen <[email protected]>
Details: https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html
[--SNIP--]
That was quite a hell of a patch...
Yeah, it is really time for upstream to make a new release with all these fixes :/
Committed to 2020.02.x, 2020.11.x and 2021.02.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard