aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-05-22 13:58:57 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-05-22 13:58:57 -0400
commit3979fdce77e6c2de97fa6c6f844ee76f001f4371 (patch)
treec5e2a223fdc8d82595b8cdf4471d7c0589078e7d
parentfbe06b7bae7c9cf6ab05168fce5ee93b2f4bae7c (diff)
parenteccaf52fee8305d5207ff110950a82c100e459bc (diff)
Merge tag 'efi-urgent' into x86/urgent
* Avoid confusing the user by returning -EIO instead of -ENOENT in efivarfs if an EFI variable gets deleted from under us and return EOF when reading from a zero-length file - Lingzhu Xiang * Fix an oops in efivar_update_sysfs_entries() caused by reusing (and therefore corrupting) a kzalloc() allocation - Seiji Aguchi * Initialise the DataSize argument to GetVariable() otherwise it will not be updated with the actual size of the variable on return. Discovered on a Acer Aspire V3 BIOS - Lee, Chun-Yi Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/platform/efi/efi.c2
-rw-r--r--drivers/firmware/efi/efivars.c8
-rw-r--r--fs/efivarfs/file.c14
3 files changed, 16 insertions, 8 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 55856b2310d3..82089d8b1954 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -206,7 +206,7 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
206 } 206 }
207 207
208 if (boot_used_size && !finished) { 208 if (boot_used_size && !finished) {
209 unsigned long size; 209 unsigned long size = 0;
210 u32 attr; 210 u32 attr;
211 efi_status_t s; 211 efi_status_t s;
212 void *tmp; 212 void *tmp;
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index b623c599e572..8bd1bb6dbe47 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -523,13 +523,11 @@ static void efivar_update_sysfs_entries(struct work_struct *work)
523 struct efivar_entry *entry; 523 struct efivar_entry *entry;
524 int err; 524 int err;
525 525
526 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
527 if (!entry)
528 return;
529
530 /* Add new sysfs entries */ 526 /* Add new sysfs entries */
531 while (1) { 527 while (1) {
532 memset(entry, 0, sizeof(*entry)); 528 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
529 if (!entry)
530 return;
533 531
534 err = efivar_init(efivar_update_sysfs_entry, entry, 532 err = efivar_init(efivar_update_sysfs_entry, entry,
535 true, false, &efivar_sysfs_list); 533 true, false, &efivar_sysfs_list);
diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index bfb531564319..8dd524f32284 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -44,8 +44,11 @@ static ssize_t efivarfs_file_write(struct file *file,
44 44
45 bytes = efivar_entry_set_get_size(var, attributes, &datasize, 45 bytes = efivar_entry_set_get_size(var, attributes, &datasize,
46 data, &set); 46 data, &set);
47 if (!set && bytes) 47 if (!set && bytes) {
48 if (bytes == -ENOENT)
49 bytes = -EIO;
48 goto out; 50 goto out;
51 }
49 52
50 if (bytes == -ENOENT) { 53 if (bytes == -ENOENT) {
51 drop_nlink(inode); 54 drop_nlink(inode);
@@ -76,7 +79,14 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
76 int err; 79 int err;
77 80
78 err = efivar_entry_size(var, &datasize); 81 err = efivar_entry_size(var, &datasize);
79 if (err) 82
83 /*
84 * efivarfs represents uncommitted variables with
85 * zero-length files. Reading them should return EOF.
86 */
87 if (err == -ENOENT)
88 return 0;
89 else if (err)
80 return err; 90 return err;
81 91
82 data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL); 92 data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);