summaryrefslogtreecommitdiff
path: root/netboot.c
AgeCommit message (Collapse)Author
2025-02-18Suppress file open failures for some netboot casesJan Setje-Eilers
Reading files during a netboot comes with the caveat that fetching files from a network does not support anything like listing a directory. In the past this has meant that we do not try to open optional files during a netboot. However at least the revocation.efi file is now tested during a netboot, which will print an error when it is not found. Since that error is spurious we should allow for those errors to be suppressed. This is also desirable since we will likely go looking for additional files in the near future. Signed-off-by: Jan Setje-Eilers <Jan.SetjeEilers@oracle.com>
2025-01-15netboot: Convert TFTP error codes to EFI status codesDan Nicholson
This allows the caller to make a more informed decision about how to handle the error. The error code is available in the TftpError field of the Mode interface. In particular, by mapping the TFTP errors to EFI_INVALID_PARAMTER and EFI_NOT_FOUND, shim will try to fetch the default second stage image like it does when loading images from disk. Unfortunately, some firmware doesn't fill in the error fields, so a generic EFI_TFTP_ERROR to EFI_NOT_FOUND conversion is included. Signed-off-by: Dan Nicholson <dbn@endlessos.org>
2024-01-22netboot read_image() should not hardcode DEFAULT_LOADERJan Setje-Eilers
The netboot path up until now hardcodes DEFAULT_LOADER as the only possible filename to load. This is pretty limiting and needs to be fixed. Signed-off-by: Jan Setje-Eilers <Jan.SetjeEilers@oracle.com>
2023-06-21Work around malformed path delimiters in file paths from DHCPAlberto Perez
shim uses path delimiters to determine the file path for the second stage. Currently only / (slash) is detected, but some DHCP implementations supply \ (backslash) as the path specifier. This patch changes it to accept either delimiter. Fixes issue #524. Signed-off-by: Alberto Perez <aperezguevar@microsoft.com>
2021-09-07cleanup: always use BS and RT, not gBS and gRTPeter Jones
This just makes one less thing we have to make sure is the same between the test harnesses and the runtime code. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Consolidate most of our standard lib functions to libPeter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-03-10Restructure our includes.Peter Jones
This re-structures our includes so we can be sure everything is always including all the system headers in a uniform, predictable way. Temporarily it also adds a bunch of junk at all the places we use variadic functions to specifically pick either the MS (cdecl) or ELF ABIs. I'm not 100% sure that's all correct (see later patch) but it's enough to allow this to build. Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-25Fix all the places we need UNUSED on arguments.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-02-16src/netboot.c: remove the execute bitGary Lin
Signed-off-by: Gary Lin <glin@suse.com>
2021-02-16Fix up a bunch of our license statements and add SPDX most placesPeter Jones
The license statements in our source files were getting to be a giant mess, and mostly they all just say the same thing. I've switched most of it to SPDX labels, but left copyright statements in place (where they were not obviously incorrect copy-paste jobs that I did...). If there's some change here you don't think is valid, let me know and we can fix it up together. Signed-off-by: Peter Jones <pjones@redhat.com>
2020-07-23Check PxeReplyReceived as fallback in netbootThomas Frauendorfer | Miray Software
Some mainboards do not update the ProxyOffset dhcp information when using proxy dhcp and boot menus. This adds a fallback to check the PxeReply field if no boot information is found in the v4 dhcp or proxy dhcp information Upstream-commit-id: cc7ebe0f9f4
2020-07-23translate_slashes(): don't write to string literalsLaszlo Ersek
Currently, all three invocations of the translate_slashes() function may lead to writes to the string literal that is #defined with the DEFAULT_LOADER_CHAR macro. According to ISO C99 6.4.5p6, this is undefined behavior ("If the program attempts to modify such an array, the behavior is undefined"). This bug crashes shim on e.g. the 64-bit ArmVirtQemu platform ("Data abort: Permission fault"), where the platform firmware maps the .text section (which contains the string literal) read-only. Modify translate_slashes() so that it copies and translates characters from an input array of "char" to an output array of "CHAR8". While at it, fix another bug. Before this patch, if translate_slashes() ever encountered a double backslash (translating it to a single forward slash), then the output would end up shorter than the input. However, the output was not NUL-terminated in-place, therefore the original string length (and according trailing garbage) would be preserved. After this patch, the NUL-termination on contraction is automatic, as the output array's contents are indeterminate when entering the function, and so we must NUL-terminate it anyway. Fixes: 8e9124227d18475d3bc634c33518963fc8db7c98 Fixes: e62b69a5b0b87c6df7a4fc23906134945309e927 Fixes: 3d79bcb2651b9eae809b975b3e03e2f96c067072 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1795654 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Upstream-commit-id: 9813e8bc8b3
2018-03-12console: Add console_print and console_print_at helpersHans de Goede
This is a preparation commit for removing the setup_console(1) calls from MokManager and shim so that we don't force the EFI console to switch to text-mode. This commit replaces all direct calls to Print / PrintAt with calls to the new helpers (no functional changes) so that we can delay calling setup_console(1) till the first Print call in a follow-up patch. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-03-12Don't use uefi_call_wrapper(), ever.Peter Jones
I'm pretty done with typing uefi_call_wrapper() and counting arguments every time. Instead, just make the compiler error if we don't have ms_abi. Also, make it so nothing can use uefi_call_wrapper() directly. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12shim: Use EFI_ERROR() instead of comparing to EFI_SUCCESS everywhere.Peter Jones
Also consistently name our status variable "efi_status" unless there's a good reason not to, such as already having another one of those. Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12Move includes around to clean the source tree up a bit.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-02-28Add proxy dhcp supportcdadmin
2017-09-13try to show errors more usefully.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2016-09-06Make translate_slashes() publicGary Ching-Pang Lin
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2014-10-02Correctly reject bad tftp addresses earlier, rather than later.Peter Jones
This check is for end == NULL but was meant to be *end == '\0'. Without this change, we'll pass a plausibly bad address (i.e. one with no ']' at the end) to Mtftp(... READ_FILE ...), which should fail correctly, but our error messaging will be inconsistent. Signed-off-by: Peter Jones <pjones@redhat.com>
2014-10-02shim buffer overflow on ipv6 option parsingSebastian Krahmer
2014-08-12Factor out x86-isms and add cross compile supportArd Biesheuvel
This patch cleans up and refactors the Makefiles to better allow new architectures to be added: - remove unused Makefile definitions - import Makefile definitions from top level rather than redefining - move x86 specific CFLAGS to inside ifeq() blocks - remove x86 inline asm - allow $(FORMAT) to be overridden: this is necessary as there exists no EFI or PE/COFF aware objcopy for ARM Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2014-06-25Fetch the netboot image from the same deviceGary Ching-Pang Lin
The previous strategy is to locate the first available PXE_BASE_CODE protocol and to fetch the second stage image from it, and this may cause shim to fetch the wrong second stage image, i.e. grub.efi. Consider the machine with the following boot order: 1. PXE Boot 2. Hard Drive Assume that the EFI image, e.g. bootx64.efi, in the PXE server is broken, then "PXE Boot" will fail and fallback to "Hard Drive". While shim.efi in "Hard Drive" is loaded, it will find the PXE protocol is available and fetch grub.efi from the PXE server, not grub.efi in the disk. This commit checks the DeviceHandle from Loaded Image. If the device supports PXE, then shim fetches grub.efi with the PXE protocol. Otherwise, shim loads grub.efi from the disk. Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2013-11-21Lengths that might be -1 can't be unsigned, Peter.Peter Jones
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-11-21Fix path generation for Dhcpv4 bootloader.Peter Jones
Right now we always look for e.g. "\grubx64.efi", which is completely wrong. This makes it look for the path shim was loaded from and modify that to end in a sanitized version of our default loader name. Resolves: rhbz#1032583 Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-02Use CHAR8 not UINT8 for character work.Peter Jones
This gets rid of a lot of type casting that we don't need, and helps reduce warnings when I switch a bunch of gnu-efi stuff to taking const arguments. Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-26Since different distros name grub*.efi differently, make it compile-time.Peter Jones
Basically, if you don't want grub.efi, you do: make 'DEFAULT_LOADER=\\\\grubx64.efi' Signed-off-by: Peter Jones <pjones@redhat.com>
2013-09-26Define the PXE 2nd stage loader in the beginning of the fileGary Ching-Pang Lin
Make it easier to change the PXE 2nd stage loader. Conflicts: netboot.c
2013-09-24Fix a memory leakSteve Langasek
2013-09-24Correct limits on the length of ipv6 addressesSteve Langasek
The maximum length of a string representation of an ipv6 address is 39 characters (8 groups of 4 hex chars, with 7 colons in between). So don't allocate more room than this - and more importantly, don't blindly accept strings from the server that are longer than our buffer...
2013-09-24More consistent types, fewer castsSteve Langasek
2013-09-24Misc allocation cleanupsSteve Langasek
2013-09-24Fix an off-by-one errorSteve Langasek
We don't need to add one because our end pointer is already off the end of the string we want to copy.
2013-09-24Fix nul termination errors in filenames passed to tftpSteve Langasek
Fix various errors in the tftp string handling, to ensure we always have properly nul-terminated strings.
2013-09-24Pass the right arguments to EFI_PXE_BASE_CODE_TFTP_READ_FILESteve Langasek
A wrong pointer was being passed to EFI_PXE_BASE_CODE_TFTP_READ_FILE, preventing us from getting the file size back from the tftp call, ensuring that we don't have enough information to properly secureboot-validate the retrieved image.
2013-05-31EFI_PXE_BASE_CODE_DHCPV6_PACKET is in gnu-efi-3.0tPeter Jones
2012-11-01Don't fail if there's no network devicesMatthew Garrett
findNetboot() would continue blindly even if no PXE-capable devices were found. Fix that.
2012-10-12Add draft version of Neil's netboot codeMatthew Garrett