efivars: Adjust the size checks

- efivars: pstore: Do not check size when erasing variable (bug introduced
  in backporting)
- efivars: Remove check for 50% full on write (this is more risky than what
  it tries to fix)

svn path=/dists/sid/linux/; revision=19938
This commit is contained in:
Ben Hutchings 2013-03-23 03:56:59 +00:00
parent 2ea813fe8d
commit 60f5e86973
4 changed files with 83 additions and 1 deletions

4
debian/changelog vendored
View File

@ -103,6 +103,8 @@ linux (3.2.41-1) unstable; urgency=low
- explicitly calculate length of VariableName
- Handle duplicate names from get_next_variable()
* efi_pstore: Introducing workqueue updating sysfs
* efivars: pstore: Do not check size when erasing variable
* efivars: Remove check for 50% full on write
* kmsg_dump: Only dump kernel log in error cases (Closes: #703386)
- kexec: remove KMSG_DUMP_KEXEC
- kmsg_dump: don't run on non-error paths by default
@ -125,7 +127,7 @@ linux (3.2.41-1) unstable; urgency=low
module, as we now have a real fix for #701784
* [rt] Update to 3.2.40-rt60
-- Ben Hutchings <ben@decadent.org.uk> Fri, 22 Mar 2013 19:38:42 +0000
-- Ben Hutchings <ben@decadent.org.uk> Sat, 23 Mar 2013 03:54:34 +0000
linux (3.2.39-2) unstable; urgency=high

View File

@ -0,0 +1,49 @@
From: Ben Hutchings <ben@decadent.org.uk>
Subject: efivars: pstore: Do not check size when erasing variable
Date: Sat, 23 Mar 2013 03:49:53 +0000
In 3.2, unlike mainline, efi_pstore_erase() calls efi_pstore_write()
with a size of 0, as the underlying EFI interface treats a size of 0
as meaning deletion.
This was not taken into account in my backport of commit d80a361d779a
'efi_pstore: Check remaining space with QueryVariableInfo() before
writing data'. The size check should be omitted when erasing.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -788,19 +788,21 @@ static int efi_pstore_write(enum pstore_
spin_lock_irqsave(&efivars->lock, flags);
- /*
- * Check if there is a space enough to log.
- * size: a size of logging data
- * DUMP_NAME_LEN * 2: a maximum size of variable name
- */
+ if (size) {
+ /*
+ * Check if there is a space enough to log.
+ * size: a size of logging data
+ * DUMP_NAME_LEN * 2: a maximum size of variable name
+ */
- status = check_var_size_locked(efivars, PSTORE_EFI_ATTRIBUTES,
- size + DUMP_NAME_LEN * 2);
+ status = check_var_size_locked(efivars, PSTORE_EFI_ATTRIBUTES,
+ size + DUMP_NAME_LEN * 2);
- if (status) {
- spin_unlock_irqrestore(&efivars->lock, flags);
- *id = part;
- return -ENOSPC;
+ if (status) {
+ spin_unlock_irqrestore(&efivars->lock, flags);
+ *id = part;
+ return -ENOSPC;
+ }
}
for (i = 0; i < DUMP_NAME_LEN; i++)

View File

@ -0,0 +1,29 @@
From: Ben Hutchings <ben@decadent.org.uk>
Subject: efivars: Remove check for 50% full on write
Date: Sat, 23 Mar 2013 02:18:42 +0000
On my EFI-booting system (AMI firmware/Asus board), the firmware does
not garbage-collect the variable store until it is rather more than
50% full, and it also updates a variable at every boot. This check
means that variable writes are guaranteed to fail after the system has
booted more than a few hundred times.
Since pstore integration is now disabled by default in Debian, we will
not normally write that much data before rebooting and giving the
firmware a chance to garbage-collect the variable store. Therefore,
until the check can be restricted to known-bad systems, it seems less
risky to disable it for now.
---
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -439,8 +439,7 @@ check_var_size_locked(struct efivars *ef
if (status != EFI_SUCCESS)
return status;
- if (!storage_size || size > remaining_size || size > max_size ||
- (remaining_size - size) < (storage_size / 2))
+ if (!storage_size || size > remaining_size || size > max_size)
return EFI_OUT_OF_RESOURCES;
return status;

View File

@ -633,3 +633,5 @@ bugfix/all/efivars-Fix-check-for-CONFIG_EFI_VARS_PSTORE_DEFAULT.patch
bugfix/all/efi_pstore-Introducing-workqueue-updating-sysfs.patch
bugfix/all/efivars-explicitly-calculate-length-of-VariableName.patch
bugfix/all/efivars-Handle-duplicate-names-from-get_next_variabl.patch
bugfix/all/efivars-pstore-do-not-check-size-when-erasing-variable.patch
debian/efivars-remove-check-for-50-full-on-write.patch