linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] efivars: Check max_size only if it is non-zero.
@ 2013-04-04 13:01 Richard Weinberger
  2013-04-04 13:01 ` [PATCH 2/2] efivars: Implement no_storage_paranoia parameter Richard Weinberger
       [not found] ` <1365080500-13677-1-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Weinberger @ 2013-04-04 13:01 UTC (permalink / raw)
  To: matt.fleming
  Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
	linux-kernel, matthew.garrett, Richard Weinberger

Some (broken?) EFI implementations return always a MaximumVariableSize of 0,
check against max_size only if it is non-zero.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/firmware/efivars.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 7acafb8..8e87f8d 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -449,7 +449,8 @@ check_var_size_locked(struct efivars *efivars, u32 attributes,
 	if (status != EFI_SUCCESS)
 		return status;
 
-	if (!storage_size || size > remaining_size || size > max_size ||
+	if (!storage_size || size > remaining_size ||
+	    (max_size && size > max_size) ||
 	    (remaining_size - size) < (storage_size / 2))
 		return EFI_OUT_OF_RESOURCES;
 
-- 
1.8.1.4

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

* [PATCH 2/2] efivars: Implement no_storage_paranoia parameter
  2013-04-04 13:01 [PATCH 1/2] efivars: Check max_size only if it is non-zero Richard Weinberger
@ 2013-04-04 13:01 ` Richard Weinberger
       [not found] ` <1365080500-13677-1-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2013-04-04 13:01 UTC (permalink / raw)
  To: matt.fleming
  Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
	linux-kernel, matthew.garrett, Richard Weinberger

Using this parameter one can disable the storage_size/2 check if
he is really sure that the UEFI does sane gc.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/firmware/efivars.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 8e87f8d..0e1d669 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -105,8 +105,10 @@ MODULE_VERSION(EFIVARS_VERSION);
 
 static bool efivars_pstore_disable =
 	IS_ENABLED(CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE);
+static bool efivars_no_storage_paranoia;
 
 module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644);
+module_param_named(no_storage_paranoia, efivars_no_storage_paranoia, bool, 0644);
 
 /*
  * The maximum size of VariableName + Data = 1024
@@ -450,7 +452,10 @@ check_var_size_locked(struct efivars *efivars, u32 attributes,
 		return status;
 
 	if (!storage_size || size > remaining_size ||
-	    (max_size && size > max_size) ||
+	    (max_size && size > max_size))
+		return EFI_OUT_OF_RESOURCES;
+
+	if (!efivars_no_storage_paranoia &&
 	    (remaining_size - size) < (storage_size / 2))
 		return EFI_OUT_OF_RESOURCES;
 
-- 
1.8.1.4

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

* RE: [PATCH 1/2] efivars: Check max_size only if it is non-zero.
       [not found] ` <1365080500-13677-1-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
@ 2013-04-04 16:00   ` Luck, Tony
  2013-04-04 16:12     ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Luck, Tony @ 2013-04-04 16:00 UTC (permalink / raw)
  To: Richard Weinberger, Fleming, Matt
  Cc: cbouatmailru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
	keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org

> Some (broken?) EFI implementations return always a MaximumVariableSize of 0,
> check against max_size only if it is non-zero.

The spec doesn't say that zero has any special meaning - so if an implementation
returns max_size == 0 but lets you set a variable to a size > 0, then I don't think
there is a need for parentheses or a "?" in this commit comment.

But if Linux silently accepts such broken EFI, then there is no feedback loop
to let EFI implementations know that they are broken.  In other areas we have
thrown out messages about firmware being broken ... perhaps:

	if (max_size == 0)
		printk_once("Broken EFI implementation is returning MaxVariableSize=0\n");

would help? After all there probably *is* a maximum size - but EFI isn't telling us what it is.

-Tony

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

* Re: [PATCH 1/2] efivars: Check max_size only if it is non-zero.
  2013-04-04 16:00   ` [PATCH 1/2] efivars: Check max_size only if it is non-zero Luck, Tony
@ 2013-04-04 16:12     ` Richard Weinberger
       [not found]       ` <515DA677.8050805-/L3Ra7n9ekc@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2013-04-04 16:12 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Fleming, Matt, cbouatmailru@gmail.com, ccross@android.com,
	keescook@chromium.org, linux-efi@vger.kernel.org,
	linux-kernel@vger.kernel.org, matthew.garrett@nebula.com

Am 04.04.2013 18:00, schrieb Luck, Tony:
>> Some (broken?) EFI implementations return always a MaximumVariableSize of 0,
>> check against max_size only if it is non-zero.
>
> The spec doesn't say that zero has any special meaning - so if an implementation
> returns max_size == 0 but lets you set a variable to a size > 0, then I don't think
> there is a need for parentheses or a "?" in this commit comment.

Thanks for the clarification.
Yesterday I've looked into the spec, but the >2000 pages hurt my brain. ;-)

> But if Linux silently accepts such broken EFI, then there is no feedback loop
> to let EFI implementations know that they are broken.  In other areas we have
> thrown out messages about firmware being broken ... perhaps:
>
> 	if (max_size == 0)
> 		printk_once("Broken EFI implementation is returning MaxVariableSize=0\n");
>
> would help? After all there probably *is* a maximum size - but EFI isn't telling us what it is.

Fair point. I'll add such a printk() to my patch and resend.

Thanks,
//richard

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

* Re: [PATCH 1/2] efivars: Check max_size only if it is non-zero.
       [not found]       ` <515DA677.8050805-/L3Ra7n9ekc@public.gmane.org>
@ 2013-04-05 14:03         ` Matt Fleming
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Fleming @ 2013-04-05 14:03 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Luck, Tony, cbouatmailru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
	keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA@public.gmane.org

On 04/04/13 17:12, Richard Weinberger wrote:
> Fair point. I'll add such a printk() to my patch and resend.

Also take a look at FW_BUG.

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

end of thread, other threads:[~2013-04-05 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04 13:01 [PATCH 1/2] efivars: Check max_size only if it is non-zero Richard Weinberger
2013-04-04 13:01 ` [PATCH 2/2] efivars: Implement no_storage_paranoia parameter Richard Weinberger
     [not found] ` <1365080500-13677-1-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
2013-04-04 16:00   ` [PATCH 1/2] efivars: Check max_size only if it is non-zero Luck, Tony
2013-04-04 16:12     ` Richard Weinberger
     [not found]       ` <515DA677.8050805-/L3Ra7n9ekc@public.gmane.org>
2013-04-05 14:03         ` 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).