Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netboot cleanup for additional files #686

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extern struct {

#define EFI_IMAGE_SECURITY_DATABASE_GUID { 0xd719b2cb, 0x3d3a, 0x4596, { 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f }}

#define SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE 1

typedef enum {
DATA_FOUND,
DATA_NOT_FOUND,
Expand Down Expand Up @@ -1091,7 +1093,8 @@ str16_to_str8(CHAR16 *str16, CHAR8 **str8)
* Load and run an EFI executable
*/
EFI_STATUS read_image(EFI_HANDLE image_handle, CHAR16 *ImagePath,
CHAR16 **PathName, void **data, int *datasize)
CHAR16 **PathName, void **data, int *datasize,
int flags)
{
EFI_STATUS efi_status;
void *sourcebuffer = NULL;
Expand Down Expand Up @@ -1130,8 +1133,9 @@ EFI_STATUS read_image(EFI_HANDLE image_handle, CHAR16 *ImagePath,
efi_status = FetchNetbootimage(image_handle, &sourcebuffer,
&sourcesize);
if (EFI_ERROR(efi_status)) {
perror(L"Unable to fetch TFTP image: %r\n",
efi_status);
if (~flags & SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE)
perror(L"Unable to fetch TFTP image: %r\n",
efi_status);
return efi_status;
}
*data = sourcebuffer;
Expand All @@ -1143,8 +1147,9 @@ EFI_STATUS read_image(EFI_HANDLE image_handle, CHAR16 *ImagePath,
&sourcesize,
netbootname);
if (EFI_ERROR(efi_status)) {
perror(L"Unable to fetch HTTP image %a: %r\n",
netbootname, efi_status);
if (~flags & SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE)
perror(L"Unable to fetch HTTP image %a: %r\n",
netbootname, efi_status);
return efi_status;
}
*data = sourcebuffer;
Expand Down Expand Up @@ -1183,7 +1188,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath)
int datasize = 0;

efi_status = read_image(image_handle, ImagePath, &PathName, &data,
&datasize);
&datasize, 0);
if (EFI_ERROR(efi_status))
goto done;

Expand Down Expand Up @@ -1459,8 +1464,12 @@ load_revocations_file(EFI_HANDLE image_handle, CHAR16 *PathName)
uint8_t *ssps_latest = NULL;
uint8_t *sspv_latest = NULL;

efi_status = read_image(image_handle, L"revocations.efi", &PathName,
&data, &datasize);
efi_status = read_image(image_handle, L"revocations_sbat.efi", &PathName,
&data, &datasize,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you missing a check for efi_status here?

SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE);
efi_status = read_image(image_handle, L"revocations_skusi.efi", &PathName,
&data, &datasize,
SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE);
if (EFI_ERROR(efi_status))
return efi_status;

Expand Down Expand Up @@ -1523,7 +1532,8 @@ load_cert_file(EFI_HANDLE image_handle, CHAR16 *filename, CHAR16 *PathName)
int i;

efi_status = read_image(image_handle, filename, &PathName,
&data, &datasize);
&data, &datasize,
SUPPRESS_NETBOOT_OPEN_FAILURE_NOISE);
if (EFI_ERROR(efi_status))
return efi_status;

Expand Down