Bug 1211101

Summary: grub2 fw_path variable is incorrect for x86 EFI network boot: too many path components stripped
Product: Red Hat Enterprise Linux 7 Reporter: Dan Callaghan <dcallagh>
Component: grub2Assignee: Peter Jones <pjones>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: alemay, mkovarik, pholica
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: grub2-2.02-0.17.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 12:23:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
grub2 patch none

Description Dan Callaghan 2015-04-13 02:28:00 UTC
Description of problem:
As of grub2-2.02-0.16, GRUB tries both $fw_path/grub.cfg-* and $prefix/grub.cfg-* when looking for its config file on a network book (bug 1148652). However on x86 EFI, $fw_path is incorrect and thus GRUB searches the wrong path.

Version-Release number of selected component (if applicable):
grub2-2.02-0.16.el7.x86_64
grub2-efi-modules-2.02-0.16.el7.x86_64

Steps to Reproduce:
1. Set up a TFTP server with the GRUB2 config and image (symlink) in a subdirectory two levels deep:
yum install tftp-server grub2-efi-modules
grub2-mknetdir -d /usr/lib/grub/x86_64-efi --net-directory /var/lib/tftpboot
mkdir -p /var/lib/tftpboot/bootloader/test5
ln -s ../../boot/grub2/x86_64-efi/core.efi /var/lib/tftpboot/bootloader/test5/image
cat >/var/lib/tftpboot/bootloader/test5/grub.cfg <<"EOF"
# put something here, doesn't really matter
EOF
systemctl start tftp.socket
2. Find an x86 EFI system, configure its DHCP with next-server=<yourtftpserver> filename=bootloader/test5/image, boot it up

Actual results:
GRUB looks for its config under /bootloader/grub.cfg-* then /boot/grub2/grub.cfg-*

Expected results:
GRUB should look for its config under /bootloader/test5/grub.cfg-* then /boot/grub2/grub.cfg-*

Additional info:
You can see GRUB's attempts to load its config if you add -vv to the TFTP server:

Apr 13 11:30:24 lab in.tftpd[17886]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-01-f0-92-1c-de-38-de
Apr 13 11:30:24 lab in.tftpd[17886]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17887]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40195E
Apr 13 11:30:24 lab in.tftpd[17887]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17888]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40195
Apr 13 11:30:24 lab in.tftpd[17888]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17889]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A4019
Apr 13 11:30:24 lab in.tftpd[17889]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17890]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A401
Apr 13 11:30:24 lab in.tftpd[17890]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17891]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40
Apr 13 11:30:24 lab in.tftpd[17891]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17892]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A4
Apr 13 11:30:24 lab in.tftpd[17892]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17893]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A
Apr 13 11:30:24 lab in.tftpd[17893]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17894]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0
Apr 13 11:30:24 lab in.tftpd[17894]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17895]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg
Apr 13 11:30:24 lab in.tftpd[17895]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17896]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-01-f0-92-1c-de-38-de
Apr 13 11:30:24 lab in.tftpd[17896]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17897]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40195E
Apr 13 11:30:24 lab in.tftpd[17897]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17898]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40195
Apr 13 11:30:24 lab in.tftpd[17898]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17899]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A4019
Apr 13 11:30:24 lab in.tftpd[17899]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17900]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A401
Apr 13 11:30:24 lab in.tftpd[17900]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17901]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40
Apr 13 11:30:24 lab in.tftpd[17901]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17902]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A4
Apr 13 11:30:24 lab in.tftpd[17902]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17903]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A
Apr 13 11:30:24 lab in.tftpd[17903]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17904]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0
Apr 13 11:30:24 lab in.tftpd[17904]: sending NAK (1, File not found) to 10.64.25.94
Apr 13 11:30:24 lab in.tftpd[17905]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg
Apr 13 11:30:24 lab in.tftpd[17905]: sending NAK (1, File not found) to 10.64.25.94

Comment 2 Dan Callaghan 2015-04-13 02:48:06 UTC
I had a poke around in GRUB's source. This is using the prepped sources from grub2-2.02-0.16.el7.

The fw_path variable is populated using the path returned from grub_machine_get_bootlocation. The EFI version of grub_machine_get_bootlocation grabs the path from either grub_efi_get_filename (if booted from disk) or grub_efi_net_config (if booted from the network) and then strips the last component from the path.

However grub_efi_net_config populates the path using grub_net_configure_by_dhcp_ack which *also* strips the last component from the path.

Comment 3 Dan Callaghan 2015-04-13 03:35:42 UTC
Created attachment 1013793 [details]
grub2 patch

The attached patch appears to fix the problem.

Comment 8 errata-xmlrpc 2015-11-19 12:23:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-2401.html