Commit Graph

14697 Commits

Author SHA1 Message Date
Julian Andres Klode
3fd986ee51 Bump SBAT to grub,4 2023-10-02 16:09:17 +02:00
Mate Kukri
279cc2d193 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>
2023-10-02 16:09:16 +02:00
Steve McIntyre
f64f291a74 Prepare 2.06-13 release 2023-05-15 23:26:08 +01:00
Steve McIntyre
fc3e9c8b0a More translation updates 2023-05-14 00:57:07 +01:00
Steve McIntyre
b1e4812335 More debconf template translations 2023-05-11 00:46:32 +01:00
Steve McIntyre
dab5d311f8 Updates to lots of the debconf template translations 2023-05-02 15:17:47 +01:00
Steve McIntyre
358e8faa13 Allow initrd to contain spaces. Closes: #838177, #820838 2023-04-23 23:08:26 +01:00
Steve McIntyre
fd7b355f25 Installing to the RMP also needs mokmanager.
Closes: #1034409
2023-04-23 23:06:26 +01:00
Steve McIntyre
effc800113 Fix up arm64 SB patch to fix build failure on 32-bit systems 2023-04-21 16:24:40 +01:00
Steve McIntyre
8818b1d731 Try again, argh printf types 2023-04-21 00:56:37 +00:00
Steve McIntyre
4f52e7f9b0 Fix 32-bit compilation 2023-04-21 00:15:13 +00:00
Steve McIntyre
93d4aaa568 Prepare 2.06-9 release 2023-04-20 21:35:31 +01:00
Steve McIntyre
1ff00c01da Close another bug with the os-prober change 2023-04-20 21:34:22 +01:00
Steve McIntyre
3cc70f6d90 Add luks2 to the signed grub efi images. Closes: #1001248 2023-04-20 21:15:26 +01:00
Steve McIntyre
160701104a Don't warn about os-prober if it's not installed. Closes: #1020769 2023-04-20 21:02:05 +01:00
Steve McIntyre
d73cec07b9 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.
2023-04-20 21:01:12 +01:00
Steve McIntyre
53aecee25b Merge branch 'arm64-sb-1033657' into 'master'
Add arm64-handover-to-kernel-if-sb-enabled.patch

See merge request grub-team/grub!32
2023-04-14 18:09:48 +00:00
Emanuele Rocca
dccded55a2 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
2023-04-03 13:37:29 +02:00
Ben Hutchings
7fd3d6f657 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
2023-03-04 22:45:46 +00:00
Steve McIntyre
47de3eb3fa Make config_item() more robust 2023-03-04 22:19:53 +00:00
Steve McIntyre
43786f0557 Import changes for the 2.06-8.1 NMU
Thanks for tracking this down Antoine!
2023-03-04 22:17:35 +00:00
Steve McIntyre
a3b9f421da Prepare 2.06-8 release 2023-02-09 01:09:11 +00:00
Colin Watson
70ba87c609 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!
2023-02-08 23:15:47 +00:00
Steve McIntyre
a892e077d3 Ignore some new ext2 flags to stay compatible with latest mke2fs
Closes: #1030846
2023-02-08 21:13:42 +00:00
Steve McIntyre
36f78fd054 grub-install: Don't use our grub CD EFI image for --removable
Closes: #1026915. Thanks to Pascal Hambourg for the patch.
2023-01-15 23:52:26 +00:00
Steve McIntyre
d6be13a9e7 Don't install fallback to removable media
It only causes problems. Closes: #1016737
2023-01-15 23:47:09 +00:00
Steve McIntyre
036c38093b /etc/default/grub: Fix comment about text-mode console
Fixes #845683
2022-12-29 20:59:36 +00:00
Steve McIntyre
44e74e2a73 postinst: be more verbose when using grub-install
to install onto devices
2022-12-29 13:39:36 +00:00
Steve McIntyre
9ba3bf3855 grub-mkconfig: Restore umask for the grub.cfg. CVE-2021-3981
Apply patch from upstream,

Closes: #1001414
2022-12-29 13:36:46 +00:00
Steve McIntyre
9df17d0bdb Include upstream patch to enable EFI zboot support on arm64
Closes: #1026092
2022-12-14 16:57:42 +00:00
Steve McIntyre
16895d90dd 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
2022-12-11 16:47:49 +00:00
Steve McIntyre
552fb31330 Fix an issue in an f2fs security fix which caused mount failures
Closes: #1021846. Thanks to программист некто for helping to debug the
problem!
2022-12-11 12:09:24 +00:00
Steve McIntyre
1fd7f8c9c9 Fix error handling in grub_file_open()
Make font fallback handling work!
2022-12-06 03:15:39 +00:00
Steve McIntyre
28632f1776 Release version 2.06-6 2022-12-04 20:42:19 +00:00
Steve McIntyre
2c1a132e34 Switch away from git-dpm 2022-12-04 18:22:27 +00:00
Steve McIntyre
e2dc71dd03 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. :-(
2022-12-04 17:08:31 +00:00
Steve McIntyre
5055c4741e 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
2022-12-04 17:02:56 +00:00
Steve McIntyre
25fe9dd841 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
2022-11-14 18:10:12 +00:00
Zhang Boyang
afa02a1bb2 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
b272bbd408 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
918f5efa88 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
f0d0d3e0d1 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
c2491cb80c 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
03d18df312 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
c274accb46 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
b24a98f935 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
96409d679a 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
abce8a8ff6 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
598911a414 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>
2022-11-12 22:51:49 +00:00
Zhang Boyang
2f01e9c03b 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>
2022-11-12 22:51:49 +00:00