]> git.proxmox.com Git - grub2.git/log
grub2.git
12 days agobump version to 2.06-13+pmx2 proxmox/bookworm
Thomas Lamprecht [Fri, 19 Apr 2024 07:30:16 +0000 (09:30 +0200)]
bump version to 2.06-13+pmx2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 days agomkrescue: add opt-in quirk for secure-boot
Thomas Lamprecht [Fri, 19 Apr 2024 07:25:11 +0000 (09:25 +0200)]
mkrescue: add opt-in quirk for secure-boot

When building the ISO we use grub-mkrescue to setup the outer GRUB on
the ISO that's used to boot the actual installer, but mkrescue sadly
has no native support to copy over the signed shim, so add that but
only enable it through an environment variable so that we do not have
to vet this overly closely as it won't affect any normal grub use
anyway, even less so as mkrescue is used rather rarely on running
systems.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agobump version to 2.06-13+pmx1
Fabian Grünbichler [Mon, 6 Nov 2023 10:18:10 +0000 (11:18 +0100)]
bump version to 2.06-13+pmx1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agoStrip grub-emu binary.
Felix Zielcke [Wed, 26 Jul 2023 18:52:15 +0000 (20:52 +0200)]
Strip grub-emu binary.

5 months agoFix lintian overrides
Julian Andres Klode [Wed, 19 Jul 2023 17:01:58 +0000 (19:01 +0200)]
Fix lintian overrides

5 months agoproxmox-grub: depend on grub-common
Fabian Grünbichler [Mon, 6 Nov 2023 10:57:31 +0000 (11:57 +0100)]
proxmox-grub: depend on grub-common

lintian is unhappy otherwise because of the /usr/share/doc/.. symlink.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agoupdate SBAT contents for Proxmox
Fabian Grünbichler [Mon, 6 Nov 2023 10:14:53 +0000 (11:14 +0100)]
update SBAT contents for Proxmox

bump grub upstream SBAT for the pulled in CVE fixes

add grub.debian entry since we mostly re-use Debian's implementation, any
Debian-specific issue almost certainly would affect ours too

keep grub.proxmox at 1 - no signatures have been created yet using the
production keys, so there is no binary in existence that would need to be
revoked.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
5 months agoMerge tag 'debian/2.06-13+deb12u1' into proxmox/bookworm
Fabian Grünbichler [Mon, 6 Nov 2023 10:13:58 +0000 (11:13 +0100)]
Merge tag 'debian/2.06-13+deb12u1' into proxmox/bookworm

grub2 Debian release 2.06-13+deb12u1

6 months agoRelease 2.06-13+deb12u1
Julian Andres Klode [Mon, 2 Oct 2023 14:20:28 +0000 (16:20 +0200)]
Release 2.06-13+deb12u1

6 months agoBump SBAT to grub,4
Julian Andres Klode [Mon, 2 Oct 2023 14:04:00 +0000 (16:04 +0200)]
Bump SBAT to grub,4

6 months agofs/ntfs: Fix various OOB reads and writes (CVE-2023-4692, CVE-2023-4693)
Mate Kukri [Thu, 28 Sep 2023 08:44:20 +0000 (09:44 +0100)]
fs/ntfs: Fix various OOB reads and writes (CVE-2023-4692, CVE-2023-4693)

This fixes the two CVEs and various other OOB bugs in the ntfs driver.

Reported-by: Maxim Suhanov <dfirblog@gmail.com>
11 months agoPrepare 2.06-13 release
Steve McIntyre [Mon, 15 May 2023 22:26:08 +0000 (23:26 +0100)]
Prepare 2.06-13 release

11 months agoMore translation updates
Steve McIntyre [Fri, 12 May 2023 16:49:19 +0000 (17:49 +0100)]
More translation updates

11 months agoMore debconf template translations
Steve McIntyre [Wed, 10 May 2023 23:46:32 +0000 (00:46 +0100)]
More debconf template translations

12 months agoUpdates to lots of the debconf template translations
Steve McIntyre [Tue, 2 May 2023 14:04:57 +0000 (15:04 +0100)]
Updates to lots of the debconf template translations

12 months agoAllow initrd to contain spaces. Closes: #838177, #820838
Steve McIntyre [Sun, 23 Apr 2023 22:08:26 +0000 (23:08 +0100)]
Allow initrd to contain spaces. Closes: #838177, #820838

12 months agoInstalling to the RMP also needs mokmanager.
Steve McIntyre [Sun, 23 Apr 2023 20:14:54 +0000 (21:14 +0100)]
Installing to the RMP also needs mokmanager.

Closes: #1034409
12 months agoFix up arm64 SB patch to fix build failure on 32-bit systems
Steve McIntyre [Fri, 21 Apr 2023 12:58:28 +0000 (13:58 +0100)]
Fix up arm64 SB patch to fix build failure on 32-bit systems

12 months agoTry again, argh printf types
Steve McIntyre [Fri, 21 Apr 2023 00:51:13 +0000 (00:51 +0000)]
Try again, argh printf types

12 months agoFix 32-bit compilation
Steve McIntyre [Thu, 20 Apr 2023 23:59:32 +0000 (00:59 +0100)]
Fix 32-bit compilation

12 months agoPrepare 2.06-9 release
Steve McIntyre [Thu, 20 Apr 2023 20:35:31 +0000 (21:35 +0100)]
Prepare 2.06-9 release

12 months agoClose another bug with the os-prober change
Steve McIntyre [Thu, 20 Apr 2023 20:34:22 +0000 (21:34 +0100)]
Close another bug with the os-prober change

12 months agoAdd luks2 to the signed grub efi images. Closes: #1001248
Steve McIntyre [Thu, 20 Apr 2023 20:15:26 +0000 (21:15 +0100)]
Add luks2 to the signed grub efi images. Closes: #1001248

12 months agoDon't warn about os-prober if it's not installed. Closes: #1020769
Steve McIntyre [Thu, 20 Apr 2023 19:59:59 +0000 (20:59 +0100)]
Don't warn about os-prober if it's not installed. Closes: #1020769

12 months agoOptionally re-enable os-prober
Steve McIntyre [Mon, 17 Apr 2023 20:59:41 +0000 (21:59 +0100)]
Optionally re-enable os-prober

Add debconf logic for GRUB_DISABLE_OS_PROBER to make it easier to
control things here. Particularly useful for the installer.
Closes: #1031594, #1012865.
12 months agoMerge branch 'arm64-sb-1033657' into 'master'
Steve McIntyre [Fri, 14 Apr 2023 18:09:48 +0000 (18:09 +0000)]
Merge branch 'arm64-sb-1033657' into 'master'

Add arm64-handover-to-kernel-if-sb-enabled.patch

See merge request grub-team/grub!32

12 months agobump version to 2.06-8.1+pmx1
Fabian Grünbichler [Mon, 20 Mar 2023 10:12:40 +0000 (11:12 +0100)]
bump version to 2.06-8.1+pmx1

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoswitch packaging to be Proxmox branded
Fabian Grünbichler [Thu, 16 Mar 2023 13:33:35 +0000 (14:33 +0100)]
switch packaging to be Proxmox branded

SBAT version is 3 (as opposed to Debian's 4) since we haven't shipped a version
3 Grub that doesn't have the version 3 fixes..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
12 months agoAdd arm64-handover-to-kernel-if-sb-enabled.patch
Emanuele Rocca [Mon, 3 Apr 2023 11:36:54 +0000 (13:36 +0200)]
Add arm64-handover-to-kernel-if-sb-enabled.patch

Fix Secure Boot on arm64 with patch
arm64-handover-to-kernel-if-sb-enabled.patch.

Fix: #1033657

13 months agoFix probing of LUKS2 devices (Closes: #1028301):
Ben Hutchings [Sat, 4 Mar 2023 22:45:46 +0000 (22:45 +0000)]
Fix probing of LUKS2 devices (Closes: #1028301):

- disk/cryptodisk: When cheatmounting, use the sector info of the cheat
  device
- osdep/devmapper/getroot: Have devmapper recognize LUKS2
- osdep/devmapper/getroot: Set up cheated LUKS2 cryptodisk mount from DM
  parameters

13 months agoMake config_item() more robust
Steve McIntyre [Thu, 23 Feb 2023 22:32:13 +0000 (22:32 +0000)]
Make config_item() more robust

13 months agoImport changes for the 2.06-8.1 NMU
Steve McIntyre [Sat, 4 Mar 2023 22:17:35 +0000 (22:17 +0000)]
Import changes for the 2.06-8.1 NMU

Thanks for tracking this down Antoine!

14 months agoPrepare 2.06-8 release
Steve McIntyre [Thu, 9 Feb 2023 01:09:11 +0000 (01:09 +0000)]
Prepare 2.06-8 release

14 months agoRemove myself from Uploaders
Colin Watson [Wed, 8 Feb 2023 23:15:47 +0000 (23:15 +0000)]
Remove myself from Uploaders

I've mostly retired from GRUB maintenance since early 2022, so I think
it would be better if I weren't listed as an uploader in bookworm.
Thanks to Steve and Julian for picking up the torch!

14 months agoIgnore some new ext2 flags to stay compatible with latest mke2fs
Steve McIntyre [Wed, 8 Feb 2023 21:13:42 +0000 (21:13 +0000)]
Ignore some new ext2 flags to stay compatible with latest mke2fs

Closes: #1030846
15 months agogrub-install: Don't use our grub CD EFI image for --removable
Steve McIntyre [Sun, 15 Jan 2023 23:52:26 +0000 (23:52 +0000)]
grub-install: Don't use our grub CD EFI image for --removable

Closes: #1026915. Thanks to Pascal Hambourg for the patch.
15 months agoDon't install fallback to removable media
Steve McIntyre [Sun, 15 Jan 2023 23:18:03 +0000 (23:18 +0000)]
Don't install fallback to removable media

It only causes problems. Closes: #1016737

16 months ago/etc/default/grub: Fix comment about text-mode console
Steve McIntyre [Thu, 29 Dec 2022 20:59:36 +0000 (20:59 +0000)]
/etc/default/grub: Fix comment about text-mode console

Fixes #845683

16 months agopostinst: be more verbose when using grub-install
Steve McIntyre [Thu, 29 Dec 2022 13:39:36 +0000 (13:39 +0000)]
postinst: be more verbose when using grub-install

to install onto devices

16 months agogrub-mkconfig: Restore umask for the grub.cfg. CVE-2021-3981
Steve McIntyre [Thu, 29 Dec 2022 13:36:46 +0000 (13:36 +0000)]
grub-mkconfig: Restore umask for the grub.cfg. CVE-2021-3981

Apply patch from upstream,

Closes: #1001414
16 months agoInclude upstream patch to enable EFI zboot support on arm64
Steve McIntyre [Wed, 14 Dec 2022 16:57:42 +0000 (16:57 +0000)]
Include upstream patch to enable EFI zboot support on arm64

Closes: #1026092
16 months agoSwitch build-deps from gcc-10 to gcc-12. Closes: #1022184
Steve McIntyre [Sun, 11 Dec 2022 12:16:40 +0000 (12:16 +0000)]
Switch build-deps from gcc-10 to gcc-12. Closes: #1022184

Also needs backports from upstream commits to fix warnings/errors
from using gcc 12:

be8eb0eed util/mkimage: Fix dangling pointer may be used error
acffb8148 build: Fix -Werror=array-bounds array subscript 0 is outside array bounds
3ce13d974 lib/reed_solomon: Fix array subscript 0 is outside array bounds

16 months agoFix an issue in an f2fs security fix which caused mount failures
Steve McIntyre [Sun, 11 Dec 2022 12:09:24 +0000 (12:09 +0000)]
Fix an issue in an f2fs security fix which caused mount failures

Closes: #1021846. Thanks to программист некто for helping to debug the
problem!

16 months agoFix error handling in grub_file_open()
Steve McIntyre [Tue, 6 Dec 2022 03:15:39 +0000 (03:15 +0000)]
Fix error handling in grub_file_open()

Make font fallback handling work!

16 months agoRelease version 2.06-6
Steve McIntyre [Sun, 4 Dec 2022 20:42:19 +0000 (20:42 +0000)]
Release version 2.06-6

16 months agoSwitch away from git-dpm
Steve McIntyre [Sun, 4 Dec 2022 18:12:20 +0000 (18:12 +0000)]
Switch away from git-dpm

16 months agoBump Debian SBAT level to 4
Steve McIntyre [Sun, 4 Dec 2022 16:43:35 +0000 (16:43 +0000)]
Bump Debian SBAT level to 4

Due to a mistake in the buster update that left the CVE-2022-2601 bugs
in place, we need to bump SBAT for all of the Debian GRUB binaries. :-(

16 months agoAdd fonts to the EFI images
Steve McIntyre [Wed, 16 Nov 2022 00:11:16 +0000 (00:11 +0000)]
Add fonts to the EFI images

The previous security updates disallowed loading unsigned fonts when
in SB mode. To make things work again:

 * Embed the "unicode" font into the embedded memdisk image so it can
   be loaded.
 * Add the memdisk to our normal grubx64.efi loader too
 * Add a patch from Chris Coulson to make the font loader look for
   fonts in the memdisk whenever they're loaded.

Closes: #1024395, #1025352, #1024447
17 months agoPull in upstream patches to harden font and image handling
Steve McIntyre [Sun, 6 Nov 2022 02:03:41 +0000 (02:03 +0000)]
Pull in upstream patches to harden font and image handling

CVE-2022-2601, CVE-2022-3775

Bump SBAT level to 3 for grub-efi packages

17 months agonormal/charset: Fix an integer overflow in grub_unicode_aglomerate_comb()
Zhang Boyang [Fri, 28 Oct 2022 13:31:39 +0000 (21:31 +0800)]
normal/charset: Fix an integer overflow in grub_unicode_aglomerate_comb()

The out->ncomb is a bit-field of 8 bits. So, the max possible value is 255.
However, code in grub_unicode_aglomerate_comb() doesn't check for an
overflow when incrementing out->ncomb. If out->ncomb is already 255,
after incrementing it will get 0 instead of 256, and cause illegal
memory access in subsequent processing.

This patch introduces GRUB_UNICODE_NCOMB_MAX to represent the max
acceptable value of ncomb. The code now checks for this limit and
ignores additional combining characters when limit is reached.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Assign null_font to glyphs in ascii_font_glyph[]
Zhang Boyang [Fri, 28 Oct 2022 09:29:16 +0000 (17:29 +0800)]
font: Assign null_font to glyphs in ascii_font_glyph[]

The calculations in blit_comb() need information from glyph's font, e.g.
grub_font_get_xheight(main_glyph->font). However, main_glyph->font is
NULL if main_glyph comes from ascii_font_glyph[]. Therefore
grub_font_get_*() crashes because of NULL pointer.

There is already a solution, the null_font. So, assign it to those glyphs
in ascii_font_glyph[].

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Harden grub_font_blit_glyph() and grub_font_blit_glyph_mirror()
Zhang Boyang [Sun, 23 Oct 2022 23:15:41 +0000 (07:15 +0800)]
font: Harden grub_font_blit_glyph() and grub_font_blit_glyph_mirror()

As a mitigation and hardening measure add sanity checks to
grub_font_blit_glyph() and grub_font_blit_glyph_mirror(). This patch
makes these two functions do nothing if target blitting area isn't fully
contained in target bitmap. Therefore, if complex calculations in caller
overflows and malicious coordinates are given, we are still safe because
any coordinates which result in out-of-bound-write are rejected. However,
this patch only checks for invalid coordinates, and doesn't provide any
protection against invalid source glyph or destination glyph, e.g.
mismatch between glyph size and buffer size.

This hardening measure is designed to mitigate possible overflows in
blit_comb(). If overflow occurs, it may return invalid bounding box
during dry run and call grub_font_blit_glyph() with malicious
coordinates during actual blitting. However, we are still safe because
the scratch glyph itself is valid, although its size makes no sense, and
any invalid coordinates are rejected.

It would be better to call grub_fatal() if illegal parameter is detected.
However, doing this may end up in a dangerous recursion because grub_fatal()
would print messages to the screen and we are in the progress of drawing
characters on the screen.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix an integer underflow in blit_comb()
Zhang Boyang [Mon, 24 Oct 2022 00:05:35 +0000 (08:05 +0800)]
font: Fix an integer underflow in blit_comb()

The expression (ctx.bounds.height - combining_glyphs[i]->height) / 2 may
evaluate to a very big invalid value even if both ctx.bounds.height and
combining_glyphs[i]->height are small integers. For example, if
ctx.bounds.height is 10 and combining_glyphs[i]->height is 12, this
expression evaluates to 2147483647 (expected -1). This is because
coordinates are allowed to be negative but ctx.bounds.height is an
unsigned int. So, the subtraction operates on unsigned ints and
underflows to a very big value. The division makes things even worse.
The quotient is still an invalid value even if converted back to int.

This patch fixes the problem by casting ctx.bounds.height to int. As
a result the subtraction will operate on int and grub_uint16_t which
will be promoted to an int. So, the underflow will no longer happen. Other
uses of ctx.bounds.height (and ctx.bounds.width) are also casted to int,
to ensure coordinates are always calculated on signed integers.

Fixes: CVE-2022-3775
Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofbutil: Fix integer overflow
Zhang Boyang [Mon, 5 Sep 2022 19:03:21 +0000 (03:03 +0800)]
fbutil: Fix integer overflow

Expressions like u64 = u32 * u32 are unsafe because their products are
truncated to u32 even if left hand side is u64. This patch fixes all
problems like that one in fbutil.

To get right result not only left hand side have to be u64 but it's also
necessary to cast at least one of the operands of all leaf operators of
right hand side to u64, e.g. u64 = u32 * u32 + u32 * u32 should be
u64 = (u64)u32 * u32 + (u64)u32 * u32.

For 1-bit bitmaps grub_uint64_t have to be used. It's safe because any
combination of values in (grub_uint64_t)u32 * u32 + u32 expression will
not overflow grub_uint64_t.

Other expressions like ptr + u32 * u32 + u32 * u32 are also vulnerable.
They should be ptr + (grub_addr_t)u32 * u32 + (grub_addr_t)u32 * u32.

This patch also adds a comment to grub_video_fb_get_video_ptr() which
says it's arguments must be valid and no sanity check is performed
(like its siblings in grub-core/video/fb/fbutil.c).

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agokern/efi/sb: Enforce verification of font files
Zhang Boyang [Sun, 14 Aug 2022 07:51:54 +0000 (15:51 +0800)]
kern/efi/sb: Enforce verification of font files

As a mitigation and hardening measure enforce verification of font
files. Then only trusted font files can be load. This will reduce the
attack surface at cost of losing the ability of end-users to customize
fonts if e.g. UEFI Secure Boot is enabled. Vendors can always customize
fonts because they have ability to pack fonts into their GRUB bundles.

This goal is achieved by:

  * Removing GRUB_FILE_TYPE_FONT from shim lock verifier's
    skip-verification list.

  * Adding GRUB_FILE_TYPE_FONT to lockdown verifier's defer-auth list,
    so font files must be verified by a verifier before they can be loaded.

Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix integer underflow in binary search of char index
Zhang Boyang [Sun, 14 Aug 2022 10:09:38 +0000 (18:09 +0800)]
font: Fix integer underflow in binary search of char index

If search target is less than all entries in font->index then "hi"
variable is set to -1, which translates to SIZE_MAX and leads to errors.

This patch fixes the problem by replacing the entire binary search code
with the libstdc++'s std::lower_bound() implementation.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix integer overflow in BMP index
Zhang Boyang [Sun, 14 Aug 2022 18:04:58 +0000 (02:04 +0800)]
font: Fix integer overflow in BMP index

The BMP index (font->bmp_idx) is designed as a reverse lookup table of
char entries (font->char_index), in order to speed up lookups for BMP
chars (i.e. code < 0x10000). The values in BMP index are the subscripts
of the corresponding char entries, stored in grub_uint16_t, while 0xffff
means not found.

This patch fixes the problem of large subscript truncated to grub_uint16_t,
leading BMP index to return wrong char entry or report false miss. The
code now checks for bounds and uses BMP index as a hint, and fallbacks
to binary-search if necessary.

On the occasion add a comment about BMP index is initialized to 0xffff.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix integer overflow in ensure_comb_space()
Zhang Boyang [Thu, 4 Aug 2022 18:27:05 +0000 (02:27 +0800)]
font: Fix integer overflow in ensure_comb_space()

In fact it can't overflow at all because glyph_id->ncomb is only 8-bit
wide. But let's keep safe if somebody changes the width of glyph_id->ncomb
in the future. This patch also fixes the inconsistency between
render_max_comb_glyphs and render_combining_glyphs when grub_malloc()
returns NULL.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Remove grub_font_dup_glyph()
Zhang Boyang [Thu, 4 Aug 2022 18:13:29 +0000 (02:13 +0800)]
font: Remove grub_font_dup_glyph()

Remove grub_font_dup_glyph() since nobody is using it since 2013, and
I'm too lazy to fix the integer overflow problem in it.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix several integer overflows in grub_font_construct_glyph()
Zhang Boyang [Thu, 4 Aug 2022 17:58:27 +0000 (01:58 +0800)]
font: Fix several integer overflows in grub_font_construct_glyph()

This patch fixes several integer overflows in grub_font_construct_glyph().
Glyphs of invalid size, zero or leading to an overflow, are rejected.
The inconsistency between "glyph" and "max_glyph_size" when grub_malloc()
returns NULL is fixed too.

Fixes: CVE-2022-2601
Reported-by: Zhang Boyang <zhangboyang.id@gmail.com>
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Fix size overflow in grub_font_get_glyph_internal()
Zhang Boyang [Thu, 4 Aug 2022 16:51:20 +0000 (00:51 +0800)]
font: Fix size overflow in grub_font_get_glyph_internal()

The length of memory allocation and file read may overflow. This patch
fixes the problem by using safemath macros.

There is a lot of code repetition like "(x * y + 7) / 8". It is unsafe
if overflow happens. This patch introduces grub_video_bitmap_calc_1bpp_bufsz().
It is safe replacement for such code. It has safemath-like prototype.

This patch also introduces grub_cast(value, pointer), it casts value to
typeof(*pointer) then store the value to *pointer. It returns true when
overflow occurs or false if there is no overflow. The semantics of arguments
and return value are designed to be consistent with other safemath macros.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agofont: Reject glyphs exceeds font->max_glyph_width or font->max_glyph_height
Zhang Boyang [Wed, 3 Aug 2022 11:45:33 +0000 (19:45 +0800)]
font: Reject glyphs exceeds font->max_glyph_width or font->max_glyph_height

Check glyph's width and height against limits specified in font's
metadata. Reject the glyph (and font) if such limits are exceeded.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17 months agovideo/readers: Add artificial limit to image dimensions
Alec Brown [Thu, 27 Oct 2022 00:16:44 +0000 (20:16 -0400)]
video/readers: Add artificial limit to image dimensions

In grub-core/video/readers/jpeg.c, the height and width of a JPEG image don't
have an upper limit for how big the JPEG image can be. In Coverity, this is
getting flagged as an untrusted loop bound. This issue can also seen in PNG and
TGA format images as well but Coverity isn't flagging it. To prevent this, the
constant IMAGE_HW_MAX_PX is being added to include/grub/bitmap.h, which has
a value of 16384, to act as an artificial limit and restrict the height and
width of images. This value was picked as it is double the current max
resolution size, which is 8K.

Fixes: CID 292450
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
19 months agoExplicitly unset SOURCE_DATE_EPOCH before running fs tests.
Steve McIntyre [Sun, 18 Sep 2022 12:50:26 +0000 (12:50 +0000)]
Explicitly unset SOURCE_DATE_EPOCH before running fs tests.

In some filesystem utils like mksquashfs, it will silently change
behaviour and cause timestamps to unexpectedly change. Reproducible
builds are good and useful for shipped artifacts, but this causes
build-time tests to fail.

19 months agoReleasing package grub2 version 2.06-4
Steve McIntyre [Wed, 14 Sep 2022 21:41:31 +0000 (22:41 +0100)]
Releasing package grub2 version 2.06-4

19 months agoDon't strip Xen binaries so they work again.
Steve McIntyre [Wed, 14 Sep 2022 21:40:29 +0000 (22:40 +0100)]
Don't strip Xen binaries so they work again.

Closes: #1017944. Thanks to Valentin Kleibel for the patch.
20 months agoAdd serial to the signed grub efi images. Closes: #1013962
Steve McIntyre [Tue, 23 Aug 2022 21:35:47 +0000 (22:35 +0100)]
Add serial to the signed grub efi images. Closes: #1013962

20 months agogrub2-common: Remove dependency on install-info
Steve McIntyre [Tue, 23 Aug 2022 21:30:06 +0000 (22:30 +0100)]
grub2-common: Remove dependency on install-info

it's apparently not needed. Closes: #1013698

20 months agoAlso close #1009336 for GRUB_DISABLE_OS_PROBER in /etc/default/grub
Steve McIntyre [Tue, 23 Aug 2022 21:24:59 +0000 (22:24 +0100)]
Also close #1009336 for GRUB_DISABLE_OS_PROBER in /etc/default/grub

20 months agoAdd smbios to the signed grub efi images. Closes: #1008106
Steve McIntyre [Tue, 23 Aug 2022 21:23:32 +0000 (22:23 +0100)]
Add smbios to the signed grub efi images. Closes: #1008106

20 months agoAdd a commented-out GRUB_DISABLE_OS_PROBER section
Steve McIntyre [Tue, 23 Aug 2022 21:14:04 +0000 (22:14 +0100)]
Add a commented-out GRUB_DISABLE_OS_PROBER section

to /etc/default/grub to make it easier for users to turn os-prober
back on if they want it. Closes: #1013797

21 months agoUpdate the 2.06-3 changelog to mention closure of CVE-2022-28736
Steve McIntyre [Sat, 30 Jul 2022 14:23:48 +0000 (15:23 +0100)]
Update the 2.06-3 changelog to mention closure of CVE-2022-28736

22 months agoreleasing package grub2 version 2.06-3
Julian Andres Klode [Fri, 10 Jun 2022 09:17:00 +0000 (11:17 +0200)]
releasing package grub2 version 2.06-3

22 months agoSecurity updates
Julian Andres Klode [Fri, 10 Jun 2022 08:30:55 +0000 (10:30 +0200)]
Security updates

22 months agomerge patched into master
Julian Andres Klode [Fri, 10 Jun 2022 08:30:47 +0000 (10:30 +0200)]
merge patched into master

22 months agofs/btrfs: Fix more fuzz issues related to chunks
Darren Kenny [Thu, 7 Apr 2022 15:18:12 +0000 (15:18 +0000)]
fs/btrfs: Fix more fuzz issues related to chunks

The corpus was generating issues in grub_btrfs_read_logical() when
attempting to iterate over stripe entries in the superblock's
bootmapping.

In most cases the reason for the failure was that the number of stripes
in chunk->nstripes exceeded the possible space statically allocated in
superblock bootmapping space. Each stripe entry in the bootmapping block
consists of a grub_btrfs_key followed by a grub_btrfs_chunk_stripe.

Another issue that came up was that while calculating the chunk size,
in an earlier piece of code in that function, depending on the data
provided in the btrfs file system, it would end up calculating a size
that was too small to contain even 1 grub_btrfs_chunk_item, which is
obviously invalid too.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agofs/btrfs: Fix more ASAN and SEGV issues found with fuzzing
Darren Kenny [Tue, 29 Mar 2022 15:52:46 +0000 (15:52 +0000)]
fs/btrfs: Fix more ASAN and SEGV issues found with fuzzing

The fuzzer is generating btrfs file systems that have chunks with
invalid combinations of stripes and substripes for the given RAID
configurations.

After examining the Linux kernel fs/btrfs/tree-checker.c code, it
appears that sub-stripes should only be applied to RAID10, and in that
case there should only ever be 2 of them.

Similarly, RAID single should only have 1 stripe, and RAID1/1C3/1C4
should have 2. 3 or 4 stripes respectively, which is what redundancy
corresponds.

Some of the chunks ended up with a size of 0, which grub_malloc() still
returned memory for and in turn generated ASAN errors later when
accessed.

While it would be possible to specifically limit the number of stripes,
a more correct test was on the combination of the chunk item, and the
number of stripes by the size of the chunk stripe structure in
comparison to the size of the chunk itself.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agofs/btrfs: Fix several fuzz issues with invalid dir item sizing
Darren Kenny [Tue, 29 Mar 2022 10:49:56 +0000 (10:49 +0000)]
fs/btrfs: Fix several fuzz issues with invalid dir item sizing

According to the btrfs code in Linux, the structure of a directory item
leaf should be of the form:

  |struct btrfs_dir_item|name|data|

in GRUB the name len and data len are in the grub_btrfs_dir_item
structure's n and m fields respectively.

The combined size of the structure, name and data should be less than
the allocated memory, a difference to the Linux kernel's struct
btrfs_dir_item is that the grub_btrfs_dir_item has an extra field for
where the name is stored, so we adjust for that too.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agofs/f2fs: Do not copy file names that are too long
Sudhakar Kuppusamy [Wed, 6 Apr 2022 12:47:43 +0000 (18:17 +0530)]
fs/f2fs: Do not copy file names that are too long

A corrupt f2fs file system might specify a name length which is greater
than the maximum name length supported by the GRUB f2fs driver.

We will allocate enough memory to store the overly long name, but there
are only F2FS_NAME_LEN bytes in the source, so we would read past the end
of the source.

While checking directory entries, do not copy a file name with an invalid
length.

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agofs/f2fs: Do not read past the end of nat bitmap
Sudhakar Kuppusamy [Wed, 6 Apr 2022 13:19:09 +0000 (18:49 +0530)]
fs/f2fs: Do not read past the end of nat bitmap

A corrupt f2fs filesystem could have a block offset or a bitmap
offset that would cause us to read beyond the bounds of the nat
bitmap.

Introduce the nat_bitmap_size member in grub_f2fs_data which holds
the size of nat bitmap.

Set the size when loading the nat bitmap in nat_bitmap_ptr(), and
catch when an invalid offset would create a pointer past the end of
the allocated space.

Check against the bitmap size in grub_f2fs_test_bit() test bit to avoid
reading past the end of the nat bitmap.

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agofs/f2fs: Do not read past the end of nat journal entries
Sudhakar Kuppusamy [Wed, 6 Apr 2022 12:33:37 +0000 (18:03 +0530)]
fs/f2fs: Do not read past the end of nat journal entries

A corrupt f2fs file system could specify a nat journal entry count
that is beyond the maximum NAT_JOURNAL_ENTRIES.

Check if the specified nat journal entry count before accessing the
array, and throw an error if it is too large.

Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/http: Error out on headers with LF without CR
Daniel Axtens [Tue, 8 Mar 2022 08:04:40 +0000 (19:04 +1100)]
net/http: Error out on headers with LF without CR

In a similar vein to the previous patch, parse_line() would write
a NUL byte past the end of the buffer if there was an HTTP header
with a LF rather than a CRLF.

RFC-2616 says:

  Many HTTP/1.1 header field values consist of words separated by LWS
  or special characters. These special characters MUST be in a quoted
  string to be used within a parameter value (as defined in section 3.6).

We don't support quoted sections or continuation lines, etc.

If we see an LF that's not part of a CRLF, bail out.

Fixes: CVE-2022-28734
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/http: Fix OOB write for split http headers
Daniel Axtens [Tue, 8 Mar 2022 07:17:03 +0000 (18:17 +1100)]
net/http: Fix OOB write for split http headers

GRUB has special code for handling an http header that is split
across two packets.

The code tracks the end of line by looking for a "\n" byte. The
code for split headers has always advanced the pointer just past the
end of the line, whereas the code that handles unsplit headers does
not advance the pointer. This extra advance causes the length to be
one greater, which breaks an assumption in parse_line(), leading to
it writing a NUL byte one byte past the end of the buffer where we
reconstruct the line from the two packets.

It's conceivable that an attacker controlled set of packets could
cause this to zero out the first byte of the "next" pointer of the
grub_mm_region structure following the current_line buffer.

Do not advance the pointer in the split header case.

Fixes: CVE-2022-28734
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/http: Do not tear down socket if it's already been torn down
Daniel Axtens [Tue, 1 Mar 2022 12:14:15 +0000 (23:14 +1100)]
net/http: Do not tear down socket if it's already been torn down

It's possible for data->sock to get torn down in tcp error handling.
If we unconditionally tear it down again we will end up doing writes
to an offset of the NULL pointer when we go to tear it down again.

Detect if it has been torn down and don't do it again.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/tftp: Avoid a trivial UAF
Daniel Axtens [Tue, 18 Jan 2022 03:29:20 +0000 (14:29 +1100)]
net/tftp: Avoid a trivial UAF

Under tftp errors, we print a tftp error message from the tftp header.
However, the tftph pointer is a pointer inside nb, the netbuff. Previously,
we were freeing the nb and then dereferencing it. Don't do that, use it
and then free it later.

This isn't really _bad_ per se, especially as we're single-threaded, but
it trips up fuzzers.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/tftp: Prevent a UAF and double-free from a failed seek
Daniel Axtens [Sun, 19 Sep 2021 15:12:24 +0000 (01:12 +1000)]
net/tftp: Prevent a UAF and double-free from a failed seek

A malicious tftp server can cause UAFs and a double free.

An attempt to read from a network file is handled by grub_net_fs_read(). If
the read is at an offset other than the current offset, grub_net_seek_real()
is invoked.

In grub_net_seek_real(), if a backwards seek cannot be satisfied from the
currently received packets, and the underlying transport does not provide
a seek method, then grub_net_seek_real() will close and reopen the network
protocol layer.

For tftp, the ->close() call goes to tftp_close() and frees the tftp_data_t
file->data. The file->data pointer is not nulled out after the free.

If the ->open() call fails, the file->data will not be reallocated and will
continue point to a freed memory block. This could happen from a server
refusing to send the requisite ack to the new tftp request, for example.

The seek and the read will then fail, but the grub_file continues to exist:
the failed seek does not necessarily cause the entire file to be thrown
away (e.g. where the file is checked to see if it is gzipped/lzio/xz/etc.,
a read failure is interpreted as a decompressor passing on the file, not as
an invalidation of the entire grub_file_t structure).

This means subsequent attempts to read or seek the file will use the old
file->data after free. Eventually, the file will be close()d again and
file->data will be freed again.

Mark a net_fs file that doesn't reopen as broken. Do not permit read() or
close() on a broken file (seek is not exposed directly to the file API -
it is only called as part of read, so this blocks seeks as well).

As an additional defence, null out the ->data pointer if tftp_open() fails.
That would have lead to a simple null pointer dereference rather than
a mess of UAFs.

This may affect other protocols, I haven't checked.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/dns: Don't read past the end of the string we're checking against
Daniel Axtens [Mon, 20 Dec 2021 10:55:43 +0000 (21:55 +1100)]
net/dns: Don't read past the end of the string we're checking against

I don't really understand what's going on here but fuzzing found
a bug where we read past the end of check_with. That's a C string,
so use grub_strlen() to make sure we don't overread it.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/dns: Fix double-free addresses on corrupt DNS response
Daniel Axtens [Wed, 15 Sep 2021 15:29:54 +0000 (01:29 +1000)]
net/dns: Fix double-free addresses on corrupt DNS response

grub_net_dns_lookup() takes as inputs a pointer to an array of addresses
("addresses") for the given name, and pointer to a number of addresses
("naddresses"). grub_net_dns_lookup() is responsible for allocating
"addresses", and the caller is responsible for freeing it if
"naddresses" > 0.

The DNS recv_hook will sometimes set and free the addresses array,
for example if the packet is too short:

      if (ptr + 10 >= nb->tail)
{
  if (!*data->naddresses)
    grub_free (*data->addresses);
  grub_netbuff_free (nb);
  return GRUB_ERR_NONE;
}

Later on the nslookup command code unconditionally frees the "addresses"
array. Normally this is fine: the array is either populated with valid
data or is NULL. But in these sorts of error cases it is neither NULL
nor valid and we get a double-free.

Only free "addresses" if "naddresses" > 0.

It looks like the other use of grub_net_dns_lookup() is not affected.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/ip: Do IP fragment maths safely
Daniel Axtens [Mon, 20 Dec 2021 08:41:21 +0000 (19:41 +1100)]
net/ip: Do IP fragment maths safely

This avoids an underflow and subsequent unpleasantness.

Fixes: CVE-2022-28733
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonet/netbuff: Block overly large netbuff allocs
Daniel Axtens [Tue, 8 Mar 2022 12:47:46 +0000 (23:47 +1100)]
net/netbuff: Block overly large netbuff allocs

A netbuff shouldn't be too huge. It's bounded by MTU and TCP segment
reassembly.

This helps avoid some bugs (and provides a spot to instrument to catch
them at their source).

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agonormal/charset: Fix array out-of-bounds formatting unicode for display
Daniel Axtens [Tue, 13 Jul 2021 03:24:38 +0000 (13:24 +1000)]
normal/charset: Fix array out-of-bounds formatting unicode for display

In some cases attempting to display arbitrary binary strings leads
to ASAN splats reading the widthspec array out of bounds.

Check the index. If it would be out of bounds, return a width of 1.
I don't know if that's strictly correct, but we're not really expecting
great display of arbitrary binary data, and it's certainly not worse than
an OOB read.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/jpeg: Block int underflow -> wild pointer write
Daniel Axtens [Wed, 7 Jul 2021 05:38:19 +0000 (15:38 +1000)]
video/readers/jpeg: Block int underflow -> wild pointer write

Certain 1 px wide images caused a wild pointer write in
grub_jpeg_ycrcb_to_rgb(). This was caused because in grub_jpeg_decode_data(),
we have the following loop:

for (; data->r1 < nr1 && (!data->dri || rst);
     data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3)

We did not check if vb * width >= hb * nc1.

On a 64-bit platform, if that turns out to be negative, it will underflow,
be interpreted as unsigned 64-bit, then be added to the 64-bit pointer, so
we see data->bitmap_ptr jump, e.g.:

0x6180_0000_0480 to
0x6181_0000_0498
     ^
     ~--- carry has occurred and this pointer is now far away from
          any object.

On a 32-bit platform, it will decrement the pointer, creating a pointer
that won't crash but will overwrite random data.

Catch the underflow and error out.

Fixes: CVE-2021-3697
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/jpeg: Refuse to handle multiple start of streams
Daniel Axtens [Mon, 28 Jun 2021 04:25:17 +0000 (14:25 +1000)]
video/readers/jpeg: Refuse to handle multiple start of streams

An invalid file could contain multiple start of stream blocks, which
would cause us to reallocate and leak our bitmap. Refuse to handle
multiple start of streams.

Additionally, fix a grub_error() call formatting.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/jpeg: Do not reallocate a given huff table
Daniel Axtens [Mon, 28 Jun 2021 04:16:58 +0000 (14:16 +1000)]
video/readers/jpeg: Do not reallocate a given huff table

Fix a memory leak where an invalid file could cause us to reallocate
memory for a huffman table we had already allocated memory for.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/jpeg: Abort sooner if a read operation fails
Daniel Axtens [Mon, 28 Jun 2021 04:16:14 +0000 (14:16 +1000)]
video/readers/jpeg: Abort sooner if a read operation fails

Fuzzing revealed some inputs that were taking a long time, potentially
forever, because they did not bail quickly upon encountering an I/O error.

Try to catch I/O errors sooner and bail out.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/png: Sanity check some huffman codes
Daniel Axtens [Tue, 6 Jul 2021 09:19:11 +0000 (19:19 +1000)]
video/readers/png: Sanity check some huffman codes

ASAN picked up two OOB global reads: we weren't checking if some code
values fit within the cplens or cpdext arrays. Check and throw an error
if not.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/png: Avoid heap OOB R/W inserting huff table items
Daniel Axtens [Tue, 6 Jul 2021 13:25:07 +0000 (23:25 +1000)]
video/readers/png: Avoid heap OOB R/W inserting huff table items

In fuzzing we observed crashes where a code would attempt to be inserted
into a huffman table before the start, leading to a set of heap OOB reads
and writes as table entries with negative indices were shifted around and
the new code written in.

Catch the case where we would underflow the array and bail.

Fixes: CVE-2021-3696
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/png: Drop greyscale support to fix heap out-of-bounds write
Daniel Axtens [Tue, 6 Jul 2021 08:51:35 +0000 (18:51 +1000)]
video/readers/png: Drop greyscale support to fix heap out-of-bounds write

A 16-bit greyscale PNG without alpha is processed in the following loop:

      for (i = 0; i < (data->image_width * data->image_height);
   i++, d1 += 4, d2 += 2)
{
  d1[R3] = d2[1];
  d1[G3] = d2[1];
  d1[B3] = d2[1];
}

The increment of d1 is wrong. d1 is incremented by 4 bytes per iteration,
but there are only 3 bytes allocated for storage. This means that image
data will overwrite somewhat-attacker-controlled parts of memory - 3 bytes
out of every 4 following the end of the image.

This has existed since greyscale support was added in 2013 in commit
3ccf16dff98f (grub-core/video/readers/png.c: Support grayscale).

Saving starfield.png as a 16-bit greyscale image without alpha in the gimp
and attempting to load it causes grub-emu to crash - I don't think this code
has ever worked.

Delete all PNG greyscale support.

Fixes: CVE-2021-3695
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/png: Refuse to handle multiple image headers
Daniel Axtens [Tue, 6 Jul 2021 04:13:40 +0000 (14:13 +1000)]
video/readers/png: Refuse to handle multiple image headers

This causes the bitmap to be leaked. Do not permit multiple image headers.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
22 months agovideo/readers/png: Abort sooner if a read operation fails
Daniel Axtens [Tue, 6 Jul 2021 04:02:55 +0000 (14:02 +1000)]
video/readers/png: Abort sooner if a read operation fails

Fuzzing revealed some inputs that were taking a long time, potentially
forever, because they did not bail quickly upon encountering an I/O error.

Try to catch I/O errors sooner and bail out.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>