diff mbox series

[v2] lib: efi_loader: Fix efi_dp_from_mem() calls

Message ID 20241030211748.1264005-1-moritzf@google.com
State New
Delegated to: Heinrich Schuchardt
Headers show
Series [v2] lib: efi_loader: Fix efi_dp_from_mem() calls | expand

Commit Message

Moritz Fischer Oct. 30, 2024, 9:17 p.m. UTC
The function expects an end address but is being called with
an size instead.

Fixes: 6422820ac3 ("efi_loader: split unrelated code from efi_bootmgr.c")
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Moritz Fischer <moritzf@google.com>
---

Changes from v1:
- Fixed second callsite
- Remove superfluous cast

---
 lib/efi_loader/efi_bootbin.c     | 1 +
 lib/efi_loader/efi_device_path.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Patrick Wildt Oct. 30, 2024, 9:21 p.m. UTC | #1
On Wed, Oct 30, 2024 at 10:18 PM Moritz Fischer <moritzf@google.com> wrote:

> The function expects an end address but is being called with
> an size instead.
>
> Fixes: 6422820ac3 ("efi_loader: split unrelated code from efi_bootmgr.c")
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Moritz Fischer <moritzf@google.com>
> ---
>
> Changes from v1:
> - Fixed second callsite
> - Remove superfluous cast
>
> ---
>  lib/efi_loader/efi_bootbin.c     | 1 +
>  lib/efi_loader/efi_device_path.c | 3 ++-
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_bootbin.c b/lib/efi_loader/efi_bootbin.c
> index a87006b3c0..bf38392fac 100644
> --- a/lib/efi_loader/efi_bootbin.c
> +++ b/lib/efi_loader/efi_bootbin.c
> @@ -137,6 +137,7 @@ efi_status_t efi_run_image(void *source_buffer,
> efi_uintn_t source_size)
>                  */
>                 file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
>                                             (uintptr_t)source_buffer,
> +                                           (uintptr_t)source_buffer +
>                                             source_size);
>                 /*
>                  * Make sure that device for device_path exist
> diff --git a/lib/efi_loader/efi_device_path.c
> b/lib/efi_loader/efi_device_path.c
> index 9de3b95d07..d7444588aa 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -1073,7 +1073,8 @@ efi_status_t efi_dp_from_name(const char *dev, const
> char *devnr,
>                 efi_get_image_parameters(&image_addr, &image_size);
>
>                 dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
> -                                    (uintptr_t)image_addr, image_size);
> +                                    (uintptr_t)image_addr,
> +                                    (uintptr_t)image_addr + image_size);
>         } else if (IS_ENABLED(CONFIG_NETDEVICES) && !strcmp(dev, "Net")) {
>                 dp = efi_dp_from_eth();
>         } else if (!strcmp(dev, "Uart")) {
> --
> 2.47.0.163.g1226f6d8fa-goog
>
>
Looks good to me, thanks!

Reviewed-by: Patrick Wildt <pwildt@google.com>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_bootbin.c b/lib/efi_loader/efi_bootbin.c
index a87006b3c0..bf38392fac 100644
--- a/lib/efi_loader/efi_bootbin.c
+++ b/lib/efi_loader/efi_bootbin.c
@@ -137,6 +137,7 @@  efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
 		 */
 		file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
 					    (uintptr_t)source_buffer,
+					    (uintptr_t)source_buffer +
 					    source_size);
 		/*
 		 * Make sure that device for device_path exist
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 9de3b95d07..d7444588aa 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -1073,7 +1073,8 @@  efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 		efi_get_image_parameters(&image_addr, &image_size);
 
 		dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
-				     (uintptr_t)image_addr, image_size);
+				     (uintptr_t)image_addr,
+				     (uintptr_t)image_addr + image_size);
 	} else if (IS_ENABLED(CONFIG_NETDEVICES) && !strcmp(dev, "Net")) {
 		dp = efi_dp_from_eth();
 	} else if (!strcmp(dev, "Uart")) {