From 2cc635d8d90912cd09464a42ba6d74cf5829c16a Mon Sep 17 00:00:00 2001 From: wanglu210 Date: Mon, 29 Aug 2022 15:36:49 +0800 Subject: [PATCH] backport patches from upstream --- ...k-Pass-buffers-with-higher-alignment.patch | 71 +++++++++++++++++++ ...port-tests-Disable-blkid-cache-usage.patch | 34 +++++++++ grub.patches | 4 +- grub2.spec | 8 ++- 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 backport-disk-efi-efidisk-Pass-buffers-with-higher-alignment.patch create mode 100644 backport-tests-Disable-blkid-cache-usage.patch diff --git a/backport-disk-efi-efidisk-Pass-buffers-with-higher-alignment.patch b/backport-disk-efi-efidisk-Pass-buffers-with-higher-alignment.patch new file mode 100644 index 0000000..0d9a332 --- /dev/null +++ b/backport-disk-efi-efidisk-Pass-buffers-with-higher-alignment.patch @@ -0,0 +1,71 @@ +From a608e6a18001227ef0b5d079a49ad3766fd742ff Mon Sep 17 00:00:00 2001 +From: Stefan Agner +Date: Tue, 31 May 2022 17:53:43 +0200 +Subject: [PATCH] disk/efi/efidisk: Pass buffers with higher alignment + +Some devices report IoAlign values but seem to require buffers with +higher alignment. + +The UEFI specification is saying: "IoAlign values of 0 and 1 mean that +the buffer can be placed anywhere in memory. Otherwise, IoAlign must +be a power of 2, and the requirement is that the start address of +a buffer must be evenly divisible by IoAlign with no remainder." + +Some devices report IoAlign of 2, however seem to require 4 bytes +aligned buffers. It seems that this got misinterpreted by some vendors +assuming IoAlign is 2^IoAlign. There is also such a hint in an example +in earlier versions of the Driver Writer's Guide: + + ScsiPassThruMode.IoAlign = 2; //Data must be aligned on 4-byte boundary + +Some devices report no alignment requirements at all but seem to read +corrupted data or report read errors when passing unaligned buffers. + +Work around by using an alignment of at least BlockSize (typically 512 +bytes) in any case. If IoAlign (interpreted as per UEFI specification) +requests a higher alignment than BlockSize, follow IoAlign still. + +Note: The problem has only noticed with compressed squashfs. It seems +that ext4 (and presumably other file system drivers) pass buffers with +a higher alignment already. + +Reference:https://git.savannah.gnu.org/cgit/grub.git/commit?id=858a0745c89262d1f35b9d3d3a208573732d7e36 +Conflict:NA + +Signed-off-by: Stefan Agner +Acked-by: Heinrich Schuchardt +Reviewed-by: Daniel Kiper + +--- + grub-core/disk/efi/efidisk.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c +index abb98aa..8a616d9 100644 +--- a/grub-core/disk/efi/efidisk.c ++++ b/grub-core/disk/efi/efidisk.c +@@ -562,8 +562,19 @@ __grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector, + d = disk->data; + bio = d->block_io; + +- /* Set alignment to 1 if 0 specified */ +- io_align = bio->media->io_align ? bio->media->io_align : 1; ++ /* ++ * If IoAlign is > 1, it should represent the required alignment. However, ++ * some UEFI implementations seem to report IoAlign=2 but require 2^IoAlign. ++ * some implementation seem to require alignment despite not reporting any ++ * specific requirements. ++ * ++ * Make sure to use buffers which are at least aligned to block size. ++ */ ++ if (bio->media->io_align < bio->media->block_size) ++ io_align = bio->media->block_size; ++ else ++ io_align = bio->media->io_align; ++ + num_bytes = size << disk->log_sector_size; + + if ((grub_addr_t) buf & (io_align - 1)) +-- +2.27.0 + diff --git a/backport-tests-Disable-blkid-cache-usage.patch b/backport-tests-Disable-blkid-cache-usage.patch new file mode 100644 index 0000000..69564b0 --- /dev/null +++ b/backport-tests-Disable-blkid-cache-usage.patch @@ -0,0 +1,34 @@ +From 3f2d3d95bf73432a112b51e9cb88c21660468d57 Mon Sep 17 00:00:00 2001 +From: Glenn Washburn +Date: Sat, 9 Apr 2022 02:44:46 +0000 +Subject: [PATCH] tests: Disable blkid cache usage + +Using the blkid cache can cause issues when running many file system tests +in parallel. We do not need it, as its only there to improve performance, +and using the cache does not provide significant performance improvements. + +Reference:https://git.savannah.gnu.org/cgit/grub.git/commit?id=e883cc6a282891783902daf2d564a5b5c7a6a5aa +Conflict:NA + +Signed-off-by: Glenn Washburn +Reviewed-by: Daniel Kiper + +--- + tests/util/grub-fs-tester.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in +index bc14a05..fb5022f 100644 +--- a/tests/util/grub-fs-tester.in ++++ b/tests/util/grub-fs-tester.in +@@ -1,6 +1,7 @@ + #!@BUILD_SHEBANG@ + + set -e ++export BLKID_FILE=/dev/null + + fs="$1" + +-- +2.27.0 + diff --git a/grub.patches b/grub.patches index b019c06..3af4d5c 100644 --- a/grub.patches +++ b/grub.patches @@ -405,4 +405,6 @@ Patch0404: backport-net-tftp-Prevent-a-UAF-and-double-free-from.patch Patch0405: backport-net-tftp-Avoid-a-trivial-UAF.patch Patch0406: backport-net-http-Do-not-tear-down-socket-if-its-already.patch Patch0407: backport-net-http-Fix-OOB-write-for-split-http-headers.patch -Patch0408: backport-net-http-Error-out-on-headers-with-LF-without-CR.patch \ No newline at end of file +Patch0408: backport-net-http-Error-out-on-headers-with-LF-without-CR.patch +Patch0409: backport-tests-Disable-blkid-cache-usage.patch +Patch0410: backport-disk-efi-efidisk-Pass-buffers-with-higher-alignment.patch diff --git a/grub2.spec b/grub2.spec index ea686a5..8fbd7d5 100644 --- a/grub2.spec +++ b/grub2.spec @@ -8,7 +8,7 @@ Name: grub2 Epoch: 1 Version: 2.04 -Release: 24 +Release: 25 Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -450,6 +450,12 @@ rm -r /boot/grub2.tmp/ || : %{_datadir}/man/man* %changelog +* Mon Aug 29 2022 wanglu - 1:2.04-25 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:tests: Disable blkid cache usage + disk/efi/efidisk: Pass buffers with higher ailgnment * Tue Jun 14 2022 chenjirong - 2.04-24 - Type:CVE