linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi: Check for null efi kernel parameters
@ 2015-06-30 23:13 Ricardo Neri
       [not found] ` <1435706013-20375-1-git-send-email-ricardo.neri-calderon-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Neri @ 2015-06-30 23:13 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Glenn P. Williamson,
	Ricardo Neri

Even though it is documented how to specify efi parameters,
it is possible to cause a kernel panic due to a NULL pointer
derreference if no efi parameter is passed. Thus, check whether
there is any parameters at all before parsing and warn the user.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 arch/x86/platform/efi/efi.c | 4 ++++
 drivers/firmware/efi/efi.c  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 51a689d..f60af0c 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -948,6 +948,10 @@ u64 efi_mem_attributes(unsigned long phys_addr)
 
 static int __init arch_parse_efi_cmdline(char *str)
 {
+	if (!str) {
+		pr_warn("need at least one option\n");
+		return -EINVAL;
+	}
 	if (parse_option_str(str, "old_map"))
 		set_bit(EFI_OLD_MEMMAP, &efi.flags);
 	if (parse_option_str(str, "debug"))
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 3c457db..c1b3fdb 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -58,6 +58,10 @@ bool efi_runtime_disabled(void)
 
 static int __init parse_efi_cmdline(char *str)
 {
+	if (!str) {
+		pr_warn("need at least one option\n");
+		return -EINVAL;
+	}
 	if (parse_option_str(str, "noruntime"))
 		disable_runtime = true;
 
-- 
1.9.1

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

end of thread, other threads:[~2015-07-20 10:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-30 23:13 [PATCH] efi: Check for null efi kernel parameters Ricardo Neri
     [not found] ` <1435706013-20375-1-git-send-email-ricardo.neri-calderon-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-07-01 13:19   ` Matt Fleming
     [not found]     ` <20150701131919.GK28334-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-07-01 17:37       ` Ricardo Neri
2015-07-20  9:34         ` Dave Young
     [not found]           ` <20150720093401.GA9763-sa4SJRhfYT7GSfWCAtytT/XAX3CI6PSWQQ4Iyu8u01E@public.gmane.org>
2015-07-20 10:11             ` Matt Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).