efi: be more paranoid about available space when creating variables
authorJosh Boyer <jwboyer@redhat.com>
Mon, 11 Mar 2013 21:48:53 +0000 (17:48 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 20 Mar 2013 15:03:28 +0000 (15:03 +0000)
commit7feecf3f2b587e535550bb3e7bf75b2fee06fccf
treeae796b8c2cd5ade24f2a984f360a50a86d4eead5
parent3b048fc196139b840d79b316405bede9b5d3c4c2
efi: be more paranoid about available space when creating variables

commit 68d929862e29a8b52a7f2f2f86a0600423b093cd upstream.

UEFI variables are typically stored in flash. For various reasons, avaiable
space is typically not reclaimed immediately upon the deletion of a
variable - instead, the system will garbage collect during initialisation
after a reboot.

Some systems appear to handle this garbage collection extremely poorly,
failing if more than 50% of the system flash is in use. This can result in
the machine refusing to boot. The safest thing to do for the moment is to
forbid writes if they'd end up using more than half of the storage space.
We can make this more finegrained later if we come up with a method for
identifying the broken machines.

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
[bwh: Backported to 3.2:
 - Drop efivarfs changes and unused check_var_size()
 - Add error codes to include/linux/efi.h, added upstream by
   commit 5d9db883761a ('efi: Add support for a UEFI variable filesystem')
 - Add efi_status_to_err(), added upstream by commit 7253eaba7b17
   ('efivarfs: Return an error if we fail to read a variable')]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/firmware/efivars.c
include/linux/efi.h