linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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
  0 siblings, 0 replies; 4+ 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] 4+ messages in thread

* [PATCH v2 1/2] efivars: Check max_size only if it is non-zero.
@ 2013-04-07 22:32 Richard Weinberger
  2013-04-07 22:32 ` [PATCH 2/2] efivars: Implement no_storage_paranoia parameter Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2013-04-07 22:32 UTC (permalink / raw)
  To: matt.fleming
  Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
	linux-kernel, matthew.garrett, Richard Weinberger

Some 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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 7acafb8..60c9899 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -449,7 +449,11 @@ 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 (!max_size && remaining_size > size)
+		printk_once(KERN_ERR FW_BUG "Broken EFI implementation is returning MaxVariableSize=0\n");
+
+	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] 4+ messages in thread

* [PATCH 2/2] efivars: Implement no_storage_paranoia parameter
  2013-04-07 22:32 [PATCH v2 1/2] efivars: Check max_size only if it is non-zero Richard Weinberger
@ 2013-04-07 22:32 ` Richard Weinberger
  2013-04-09  9:38   ` Matt Fleming
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2013-04-07 22:32 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 60c9899..0926471 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
@@ -453,7 +455,10 @@ check_var_size_locked(struct efivars *efivars, u32 attributes,
 		printk_once(KERN_ERR FW_BUG "Broken EFI implementation is returning MaxVariableSize=0\n");
 
 	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] 4+ messages in thread

* Re: [PATCH 2/2] efivars: Implement no_storage_paranoia parameter
  2013-04-07 22:32 ` [PATCH 2/2] efivars: Implement no_storage_paranoia parameter Richard Weinberger
@ 2013-04-09  9:38   ` Matt Fleming
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Fleming @ 2013-04-09  9:38 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: matt.fleming, cbouatmailru, ccross, keescook, tony.luck,
	linux-efi, linux-kernel, matthew.garrett

On 07/04/13 23:32, Richard Weinberger wrote:
> 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(-)

You need to make it clear that enabling this option may brick your
machine if your firmware is buggy.

-- 
Matt Fleming, Intel Open Source Technology Center

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

end of thread, other threads:[~2013-04-09  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-07 22:32 [PATCH v2 1/2] efivars: Check max_size only if it is non-zero Richard Weinberger
2013-04-07 22:32 ` [PATCH 2/2] efivars: Implement no_storage_paranoia parameter Richard Weinberger
2013-04-09  9:38   ` Matt Fleming
  -- strict thread matches above, loose matches on Subject: below --
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

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