Public bug reported:

Description

When using the traditional BIOS boot mode, Ubuntu's GRUB2 package grub2
(2.14-2ubuntu3) fails to boot a Linux kernel and initrd located on an
NTFS filesystem.

The following errors are displayed during boot:

error: run offset out of range.
error: you need to load the kernel first

The same NTFS filesystem and the same kernel/initrd files can be
successfully booted using the older GRUB2 version:

grub2 2.12-9

I have verified that the target NTFS filesystem is healthy and does not
contain any filesystem errors.

Analysis

After analyzing the GRUB2 source code, I found that the issue is related
to the read_data() function in ntfs.c.

In Ubuntu's GRUB2 package:

grub2 2.14-2ubuntu3

the following additional check was introduced:

if ((run_offset + pa) >= end_ptr || ((run_offset + pa) >= (at->end)))
return grub_error (GRUB_ERR_BAD_FS, "run offset out of range");

This check causes valid NTFS data reads to be incorrectly treated as
out-of-range access.

As a result, GRUB returns:

error: run offset out of range

and eventually fails to load the kernel:

error: you need to load the kernel first

After reverting this change and using the previous implementation from
GRUB2 2.12-9, the system boots normally.

Therefore, I suspect that this additional boundary check may introduce a
regression and incorrectly reject valid NTFS runlist offsets in some
cases.

Expected behavior

GRUB2 should be able to correctly read Linux kernel and initrd files
from a valid NTFS filesystem and continue the boot process.

Actual behavior

GRUB2 fails to load the kernel:

error: run offset out of range.
error: you need to load the kernel first
Test environment
Ubuntu GRUB2 version:
grub2 2.14-2ubuntu3
Working version:
grub2 2.12-9
Boot mode:
Legacy BIOS / traditional BIOS boot
Filesystem:
NTFS
Kernel and initrd location:
NTFS filesystem
Additional issue: Ubuntu GRUB2 cannot chainload Windows EFI bootloader

There is another issue with Ubuntu's GRUB2 EFI chainloader.

Ubuntu GRUB2 currently cannot correctly chainload Windows EFI
installations. Debian has already fixed this issue, and Ubuntu should
merge the corresponding patches.

The following patches are already included in Debian:

upstream/efi-chainloader-set-loaded-image-device-path.patch
upstream/efi-linux-set-loaded-image-device-path.patch

Debian patch series:

https://salsa.debian.org/grub-
team/grub/-/blob/debian/2.14-3/debian/patches/series?ref_type=tags#L70

I suggest that Ubuntu merge these fixes into its GRUB2 package.

Request

Please consider:

Investigating the NTFS regression introduced in grub2 2.14-2ubuntu3;
Reviewing the additional boundary check in ntfs.c and verifying whether it can 
incorrectly reject valid NTFS runlist offsets;
Importing the Debian EFI chainloader fixes into Ubuntu's GRUB2 package.

Thank you.

** Affects: grub2 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2161498

Title:
  GRUB2 2.14-2ubuntu3 cannot boot Linux kernel and initrd from NTFS
  filesystem

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2161498/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to