public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi: libstub: only free priv.runtime_map when allocated
@ 2024-04-23 13:36 Hagar Hemdan
  2024-04-23 13:40 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Hagar Hemdan @ 2024-04-23 13:36 UTC (permalink / raw)
  Cc: Maximilian Heyne, Pratyush Yadav, Norbert Manthey, stable,
	Hagar Hemdan, Ard Biesheuvel, linux-efi, linux-kernel

priv.runtime_map is only allocated when efi_novamap is not set.
Otherwise, it is an uninitialized value.
In the error path, it is freed unconditionally.
Avoid passing an uninitialized value to free_pool.
Free priv.runtime_map only when it was allocated.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: f80d26043af9 ("efi: libstub: avoid efi_get_memory_map() for allocating the virt map")
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
---
 drivers/firmware/efi/libstub/fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 70e9789ff9de..6a337f1f8787 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -335,8 +335,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
 
 fail:
 	efi_free(fdt_size, fdt_addr);
-
-	efi_bs_call(free_pool, priv.runtime_map);
+	if (!efi_novamap)
+		efi_bs_call(free_pool, priv.runtime_map);
 
 	return EFI_LOAD_ERROR;
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efi: libstub: only free priv.runtime_map when allocated
  2024-04-23 13:36 [PATCH] efi: libstub: only free priv.runtime_map when allocated Hagar Hemdan
@ 2024-04-23 13:40 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2024-04-23 13:40 UTC (permalink / raw)
  To: Hagar Hemdan; +Cc: stable, oe-kbuild-all

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] efi: libstub: only free priv.runtime_map when allocated
Link: https://lore.kernel.org/stable/20240423133635.19679-1-hagarhem%40amazon.com

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-23 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 13:36 [PATCH] efi: libstub: only free priv.runtime_map when allocated Hagar Hemdan
2024-04-23 13:40 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox