Skip to contentSkip to conversation

lib: efi_loader: Fix efi_dp_from_mem() call

PATCH Superseded Moritz Fischer 3 participants 4 messages Oct 30, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: efi_loader: Fix efi_dp_from_mem() call

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")
---
 lib/efi_loader/efi_bootbin.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/efi_loader/efi_bootbin.c +2 -1
index a87006b3c0..798bcd6eee 100644
@@ -137,7 +137,8 @@ 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,
-					    source_size);
+					    (uintptr_t)source_buffer +
+					    (size_t)source_size);
 		/*
 		 * Make sure that device for device_path exist
 		 * in load_image(). Otherwise, shell and grub will fail.
Signature · 1 line
2.47.0.163.g1226f6d8fa-goog
Reviewed-by on v1 1/1
#1 lore raw

Hi Moritz

Thanks for the patch

Quoted 15 lines · Moritz Fischer

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")
---
 lib/efi_loader/efi_bootbin.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/efi_loader/efi_bootbin.c +0 -0
index a87006b3c0..798bcd6eee 100644

lib/efi_loader/efi_bootbin.c efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) · line 141

Quoted 6 lines
lib/efi_loader/efi_bootbin.c +2 -1
@@ -137,7 +137,8 @@ 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,
-                                           source_size);
+                                           (uintptr_t)source_buffer +
+                                           (size_t)source_size);

Yes, the change is correct, but we don't need the cast.

With that changed

Quoted 6 lines
lib/efi_loader/efi_bootbin.c +0 -1
                /*
                 * Make sure that device for device_path exist
                 * in load_image(). Otherwise, shell and grub will fail.
--

2.47.0.163.g1226f6d8fa-goog

#2 lore raw
Quoted 29 lines · Ilias Apalodimas

Hi Moritz

Thanks for the patch

Quoted 5 lines · Moritz Fischer

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")

lib/efi_loader/efi_bootbin.c efi_status_t efi_run_image(void *source_buffer,

Quoted 10 lines
---
 lib/efi_loader/efi_bootbin.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/efi_loader/efi_bootbin.c +0 -0
index a87006b3c0..798bcd6eee 100644
@@ -137,7 +137,8 @@ efi_status_t efi_run_image(void *source_buffer,  

efi_uintn_t source_size)

lib/efi_loader/efi_bootbin.c efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) · line 141

Quoted 6 lines
lib/efi_loader/efi_bootbin.c +2 -1
                 */
                file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
                                            (uintptr_t)source_buffer,
-                                           source_size);
+                                           (uintptr_t)source_buffer +
+                                           (size_t)source_size);
Quoted 4 lines

Yes, the change is correct, but we don't need the cast.

With that changed

Ack. Will send a v2.

Quoted 6 lines
Quoted 6 lines
lib/efi_loader/efi_bootbin.c +0 -1
                /*
                 * Make sure that device for device_path exist
                 * in load_image(). Otherwise, shell and grub will fail.
--

2.47.0.163.g1226f6d8fa-goog

Thanks,
Moritz

Reviewed-by on v1 1/1
#3 lore raw
In reply to Moritz Fischer
Quoted 14 lines · Moritz Fischer

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")
---
  lib/efi_loader/efi_bootbin.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
lib/efi_loader/efi_bootbin.c +0 -0
index a87006b3c0..798bcd6eee 100644

lib/efi_loader/efi_bootbin.c efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) · line 144

Quoted 9 lines
lib/efi_loader/efi_bootbin.c +2 -1
@@ -137,7 +137,8 @@ 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,
-					    source_size);
+					    (uintptr_t)source_buffer +
+					    (size_t)source_size);
  		/*
  		 * Make sure that device for device_path exist
  		 * in load_image(). Otherwise, shell and grub will fail.

The efi_dp_from_mem() invocation in efi_dp_from_name() seems also to be affected.