Skip to content
Snippets Groups Projects
  1. Dec 14, 2022
  2. Dec 11, 2022
  3. Dec 06, 2022
  4. Dec 04, 2022
    • Steve McIntyre's avatar
      Release version 2.06-6 · 28632f17
      Steve McIntyre authored
      debian/2.06-6
      28632f17
    • Steve McIntyre's avatar
      Switch away from git-dpm · 2c1a132e
      Steve McIntyre authored
      2c1a132e
    • Steve McIntyre's avatar
      Bump Debian SBAT level to 4 · e2dc71dd
      Steve McIntyre authored
      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. :-(
      e2dc71dd
    • Steve McIntyre's avatar
      Add fonts to the EFI images · 5055c474
      Steve McIntyre authored
      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
      5055c474
  5. Nov 14, 2022
  6. Nov 12, 2022
    • Zhang Boyang's avatar
      normal/charset: Fix an integer overflow in grub_unicode_aglomerate_comb() · afa02a1b
      Zhang Boyang authored
      
      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: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      afa02a1b
    • Zhang Boyang's avatar
      font: Assign null_font to glyphs in ascii_font_glyph[] · b272bbd4
      Zhang Boyang authored
      
      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: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      b272bbd4
    • Zhang Boyang's avatar
      font: Harden grub_font_blit_glyph() and grub_font_blit_glyph_mirror() · 918f5efa
      Zhang Boyang authored
      
      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: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      918f5efa
    • Zhang Boyang's avatar
      font: Fix an integer underflow in blit_comb() · f0d0d3e0
      Zhang Boyang authored
      
      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: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      f0d0d3e0
    • Zhang Boyang's avatar
      fbutil: Fix integer overflow · c2491cb8
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      c2491cb8
    • Zhang Boyang's avatar
      kern/efi/sb: Enforce verification of font files · 03d18df3
      Zhang Boyang authored
      
      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: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      03d18df3
    • Zhang Boyang's avatar
      font: Fix integer underflow in binary search of char index · c274accb
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      c274accb
    • Zhang Boyang's avatar
      font: Fix integer overflow in BMP index · b24a98f9
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      b24a98f9
    • Zhang Boyang's avatar
      font: Fix integer overflow in ensure_comb_space() · 96409d67
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      96409d67
    • Zhang Boyang's avatar
      font: Remove grub_font_dup_glyph() · abce8a8f
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      abce8a8f
    • Zhang Boyang's avatar
      font: Fix several integer overflows in grub_font_construct_glyph() · 598911a4
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      598911a4
    • Zhang Boyang's avatar
      font: Fix size overflow in grub_font_get_glyph_internal() · 2f01e9c0
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      2f01e9c0
    • Zhang Boyang's avatar
      font: Reject glyphs exceeds font->max_glyph_width or font->max_glyph_height · 280a9f21
      Zhang Boyang authored
      
      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: default avatarZhang Boyang <zhangboyang.id@gmail.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      280a9f21
    • Alec Brown's avatar
      video/readers: Add artificial limit to image dimensions · 85856560
      Alec Brown authored
      
      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: default avatarAlec Brown <alec.r.brown@oracle.com>
      Reviewed-by: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      85856560
  7. Sep 18, 2022
  8. Sep 14, 2022
  9. Aug 23, 2022
  10. Jul 30, 2022
  11. Jun 10, 2022
  12. Jun 08, 2022
    • Darren Kenny's avatar
      fs/btrfs: Fix more fuzz issues related to chunks · 589500ad
      Darren Kenny authored
      
      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: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      589500ad
    • Darren Kenny's avatar
      fs/btrfs: Fix more ASAN and SEGV issues found with fuzzing · 22976cf1
      Darren Kenny authored
      
      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: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      22976cf1
    • Darren Kenny's avatar
      fs/btrfs: Fix several fuzz issues with invalid dir item sizing · 23c785c3
      Darren Kenny authored
      
      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: default avatarDarren Kenny <darren.kenny@oracle.com>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      23c785c3
    • Sudhakar Kuppusamy's avatar
      fs/f2fs: Do not copy file names that are too long · 998bd74c
      Sudhakar Kuppusamy authored
      
      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: default avatarSudhakar Kuppusamy <sudhakar@linux.ibm.com>
      Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      998bd74c
    • Sudhakar Kuppusamy's avatar
      fs/f2fs: Do not read past the end of nat bitmap · 9561d7ef
      Sudhakar Kuppusamy authored
      
      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: default avatarSudhakar Kuppusamy <sudhakar@linux.ibm.com>
      Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      9561d7ef
Loading