diff options
| author | Heinrich Schuchardt <[email protected]> | 2025-12-15 13:42:51 +0100 |
|---|---|---|
| committer | Heinrich Schuchardt <[email protected]> | 2025-12-24 08:28:51 +0100 |
| commit | 7ed2098fa9a5d0132c4f37baca8a6247a8ef5548 (patch) | |
| tree | 1320d86f0d6ffbce04a2b6040a2ae5bd012cca9c /lib | |
| parent | baf076aeb32dcdd2b022405088c3288ffc160fcf (diff) | |
efi_selftest: Enhance LoadImage test
Check that only a file system installed on a handle for the
device-path node immediately preceding the file path node is
used for LoadImage().
LoadImage() ends up invoking efi_dp_find_obj(). This test helped to
demonstrate an issue in a suggested patch to change that function.
The test can be run with:
setenv efi_selftest load image from file
bootefi selftest
Reviewed-by: Ilias Apalodimas <[email protected]>
Signed-off-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/efi_selftest/efi_selftest_loadimage.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/efi_selftest/efi_selftest_loadimage.c b/lib/efi_selftest/efi_selftest_loadimage.c index 24548f1ae63..967eaa58c69 100644 --- a/lib/efi_selftest/efi_selftest_loadimage.c +++ b/lib/efi_selftest/efi_selftest_loadimage.c @@ -125,6 +125,44 @@ static struct { } }; +/* Incorrect file device path */ +static struct { + struct efi_device_path_vendor vendor; + struct efi_device_path_controller ctrl; + struct efi_device_path path; + u16 file[sizeof(FILE_NAME)]; + struct efi_device_path end; +} __packed dp_file2 = { + .vendor = { + .dp = { + .type = DEVICE_PATH_TYPE_HARDWARE_DEVICE, + .sub_type = DEVICE_PATH_SUB_TYPE_VENDOR, + .length = sizeof(struct efi_device_path_vendor), + }, + .guid = EFI_GUID(0x4f9a0ebf, 0xa179, 0x88a6, 0x25, 0x68, + 0x10, 0x72, 0xb1, 0x93, 0x51, 0x71), + }, + .ctrl = { + .dp = { + .type = DEVICE_PATH_TYPE_HARDWARE_DEVICE, + .sub_type = DEVICE_PATH_SUB_TYPE_CONTROLLER, + .length = sizeof(struct efi_device_path_controller), + }, + .controller_number = 1, + }, + .path = { + .type = DEVICE_PATH_TYPE_MEDIA_DEVICE, + .sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH, + .length = sizeof(struct efi_device_path) + sizeof(dp_file.file), + }, + .file = FILE_NAME, + .end = { + .type = DEVICE_PATH_TYPE_END, + .sub_type = DEVICE_PATH_SUB_TYPE_END, + .length = sizeof(struct efi_device_path), + } +}; + /* File system info */ static struct file_system_info priv_file_system_info = { { @@ -517,6 +555,13 @@ static int execute(void) return EFI_ST_FAILURE; } + ret = boottime->load_image(false, handle_image, &dp_file2.vendor.dp, + NULL, 0, &handle); + if (ret == EFI_SUCCESS) { + efi_st_error("Invalid file path accepted\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } |
