[PATCH] efivarfs: fix abnormal GUID in variable name by using strcpy to replace null with dash

From: Lee, Chun-Yi
Date: Thu Feb 28 2013 - 22:21:34 EST

From: Michael Schroeder <mls@xxxxxxxx>

On HP z220 system (firmware version 1.54), some EFI variables are incorrectly
named :

ls -d /sys/firmware/efi/vars/*8be4d* | grep -v -- -8be returns

That causes by the following statement in efivar_create_sysfs_entry function:

*(short_name + strlen(short_name)) = '-';
efi_guid_unparse(vendor_guid, short_name + strlen(short_name));

The trailing \0 is overwritten with '-', but the next char doesn't seem to be a \0
as well for HP. So, the second strlen return the point of next '\0', causes there
have garbage string attached before GUID.

Tested on On HP z220.

Cc: Matt Fleming <matt@xxxxxxxxxxxxxxxxx>
Cc: Josh Boyer <jwboyer@xxxxxxxxxx>
Cc: Jeremy Kerr <jeremy.kerr@xxxxxxxxxxxxx>
Cc: Michael Schroeder <mls@xxxxxxxx>
Reported-by: Frederic Crozat <fcrozat@xxxxxxxx>
Tested-by: Frederic Crozat <fcrozat@xxxxxxxx>
Signed-off-by: Lee, Chun-Yi <jlee@xxxxxxxx>
drivers/firmware/efivars.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 8bcb595..fbf18ff 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -1708,7 +1708,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
/* This is ugly, but necessary to separate one vendor's
private variables from another's. */

- *(short_name + strlen(short_name)) = '-';
+ strcpy(short_name + strlen(short_name), "-");
efi_guid_unparse(vendor_guid, short_name + strlen(short_name));

new_efivar->kobj.kset = efivars->kset;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/