* [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[parent not found: <1435706013-20375-1-git-send-email-ricardo.neri-calderon-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* Re: [PATCH] efi: Check for null efi kernel parameters [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> 0 siblings, 1 reply; 5+ messages in thread From: Matt Fleming @ 2015-07-01 13:19 UTC (permalink / raw) To: Ricardo Neri Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Glenn P. Williamson, Dave Young (Pulling in Dave because he wrote parse_option_str()) On Tue, 30 Jun, at 04:13:33PM, Ricardo Neri wrote: > 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(+) Did you hit this by passing "efi=" on the kernel command line? I would have assumed that the generic early param parsing code would have caught this problem since it's obviously a potential issue for every other early_param() function, and so needs to be solved in a more general way. > 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 > -- Matt Fleming, Intel Open Source Technology Center ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20150701131919.GK28334-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>]
* Re: [PATCH] efi: Check for null efi kernel parameters [not found] ` <20150701131919.GK28334-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org> @ 2015-07-01 17:37 ` Ricardo Neri 2015-07-20 9:34 ` Dave Young 0 siblings, 1 reply; 5+ messages in thread From: Ricardo Neri @ 2015-07-01 17:37 UTC (permalink / raw) To: Matt Fleming Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Glenn P. Williamson, Dave Young On Wed, 2015-07-01 at 14:19 +0100, Matt Fleming wrote: > Did you hit this by passing "efi=" on the kernel command line? I hit this by passing "efi" alone. "efi=" works well because the pointer points to a valid string that only contains \0. > > I would have assumed that the generic early param parsing code would > have caught this problem since it's obviously a potential issue for > every other early_param() function, and so needs to be solved in a > more > general way. Yes, I was dubious on where to apply the patch. I saw that parse_option_str does not check for the validity of the pointers. That might seem to be a more general fix. I'll take that route. Thanks and BR, Ricardo ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] efi: Check for null efi kernel parameters 2015-07-01 17:37 ` Ricardo Neri @ 2015-07-20 9:34 ` Dave Young [not found] ` <20150720093401.GA9763-sa4SJRhfYT7GSfWCAtytT/XAX3CI6PSWQQ4Iyu8u01E@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Dave Young @ 2015-07-20 9:34 UTC (permalink / raw) To: Ricardo Neri Cc: Matt Fleming, linux-efi-u79uwXL29TY76Z2rM5mHXA, Glenn P. Williamson Matt/Ricardo, thanks for ccing me, and sorry for late response I thought to reply but I was busy on other things.. On 07/01/15 at 10:37am, Ricardo Neri wrote: > On Wed, 2015-07-01 at 14:19 +0100, Matt Fleming wrote: > > Did you hit this by passing "efi=" on the kernel command line? > > I hit this by passing "efi" alone. "efi=" works well because the pointer > points to a valid string that only contains \0. > > > > I would have assumed that the generic early param parsing code would > > have caught this problem since it's obviously a potential issue for > > every other early_param() function, and so needs to be solved in a > > more > > general way. > > Yes, I was dubious on where to apply the patch. I saw that > parse_option_str does not check for the validity of the pointers. That > might seem to be a more general fix. I'll take that route. Ricardo, I agree to fix it in parse_option_str. Do you have sent any update ? Thanks Dave ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20150720093401.GA9763-sa4SJRhfYT7GSfWCAtytT/XAX3CI6PSWQQ4Iyu8u01E@public.gmane.org>]
* Re: [PATCH] efi: Check for null efi kernel parameters [not found] ` <20150720093401.GA9763-sa4SJRhfYT7GSfWCAtytT/XAX3CI6PSWQQ4Iyu8u01E@public.gmane.org> @ 2015-07-20 10:11 ` Matt Fleming 0 siblings, 0 replies; 5+ messages in thread From: Matt Fleming @ 2015-07-20 10:11 UTC (permalink / raw) To: Dave Young Cc: Ricardo Neri, linux-efi-u79uwXL29TY76Z2rM5mHXA, Glenn P. Williamson On Mon, 20 Jul, at 05:34:01PM, Dave Young wrote: > > Ricardo, I agree to fix it in parse_option_str. Do you have sent any > update ? Ricardo actually went with a different solution to fixing parse_option_str(), http://article.gmane.org/gmane.linux.kernel.efi/5865 -- Matt Fleming, Intel Open Source Technology Center ^ permalink raw reply [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).