All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
@ 2012-10-26 21:43 ` Seiji Aguchi
  0 siblings, 0 replies; 6+ messages in thread
From: Seiji Aguchi @ 2012-10-26 21:43 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA, mikew-hpIqsD4AKlfQT0dZR+AlfA,
	Luck, Tony (tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org),
	Matthew Garrett (mjg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org),
	dzickus-H+wXaHxf7aLQT0dZR+AlfA
  Cc: dle-develop-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Satoru Moriya

[Issue]

A format of variable name has been updated to type, id, count and ctime
to support holding multiple logs.

Format of current variable name
  dump-type0-1-2-12345678

  type:0
  id:1
  count:2
  ctime:12345678

On the other hand, if an old variable name before being updated 
remains, users can't erase it via /dev/pstore.

Format of old variable name
  dump-type0-1-12345678

  type:0
  id:1
  ctime:12345678

[Solution]

This patch adds a format check for the old variable name in a erase callback to make it erasable.

Signed-off-by: Seiji Aguchi <seiji.aguchi-7rDLJAbr9SE@public.gmane.org>
---
 drivers/firmware/efivars.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index dd228d5..b1cd028 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -777,6 +777,8 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 	struct efivars *efivars = psi->data;
 	struct efivar_entry *entry, *found = NULL;
 	int i;
+	unsigned int type_old, part_old;
+	unsigned long time_old;
 
 	sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
 		time.tv_sec);
@@ -796,8 +798,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 		if (efi_guidcmp(entry->var.VendorGuid, vendor))
 			continue;
 		if (utf16_strncmp(entry->var.VariableName, efi_name,
-				  utf16_strlen(efi_name)))
-			continue;
+				  utf16_strlen(efi_name))) {
+			/*
+			 * Check if an old format,
+			 * which doesn't support holding
+			 * multiple logs, remains.
+			 */
+			if (sscanf(name, "dump-type%u-%u-%lu",
+				   &type_old, &part_old, &time_old) != 3)
+				continue;
+		}
 
 		/* found */
 		found = entry;
-- 1.7.1

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

* [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
@ 2012-10-26 21:43 ` Seiji Aguchi
  0 siblings, 0 replies; 6+ messages in thread
From: Seiji Aguchi @ 2012-10-26 21:43 UTC (permalink / raw)
  To: linux-kernel, linux-efi, linux-acpi, mikew, Luck,
	Tony (tony.luck@intel.com), Matthew Garrett (mjg@redhat.com),
	dzickus
  Cc: dle-develop, Satoru Moriya

[Issue]

A format of variable name has been updated to type, id, count and ctime
to support holding multiple logs.

Format of current variable name
  dump-type0-1-2-12345678

  type:0
  id:1
  count:2
  ctime:12345678

On the other hand, if an old variable name before being updated 
remains, users can't erase it via /dev/pstore.

Format of old variable name
  dump-type0-1-12345678

  type:0
  id:1
  ctime:12345678

[Solution]

This patch adds a format check for the old variable name in a erase callback to make it erasable.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
---
 drivers/firmware/efivars.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index dd228d5..b1cd028 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -777,6 +777,8 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 	struct efivars *efivars = psi->data;
 	struct efivar_entry *entry, *found = NULL;
 	int i;
+	unsigned int type_old, part_old;
+	unsigned long time_old;
 
 	sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
 		time.tv_sec);
@@ -796,8 +798,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 		if (efi_guidcmp(entry->var.VendorGuid, vendor))
 			continue;
 		if (utf16_strncmp(entry->var.VariableName, efi_name,
-				  utf16_strlen(efi_name)))
-			continue;
+				  utf16_strlen(efi_name))) {
+			/*
+			 * Check if an old format,
+			 * which doesn't support holding
+			 * multiple logs, remains.
+			 */
+			if (sscanf(name, "dump-type%u-%u-%lu",
+				   &type_old, &part_old, &time_old) != 3)
+				continue;
+		}
 
 		/* found */
 		found = entry;
-- 1.7.1

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

* Re: [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
  2012-10-26 21:43 ` Seiji Aguchi
@ 2012-10-29 20:24   ` Mike Waychison
  -1 siblings, 0 replies; 6+ messages in thread
From: Mike Waychison @ 2012-10-29 20:24 UTC (permalink / raw)
  To: Seiji Aguchi
  Cc: linux-kernel, linux-efi, linux-acpi, Luck,
	Tony (tony.luck@intel.com), Matthew Garrett (mjg@redhat.com),
	dzickus, dle-develop, Satoru Moriya

On Fri, Oct 26, 2012 at 2:43 PM, Seiji Aguchi <seiji.aguchi@hds.com> wrote:
> [Issue]
>
> A format of variable name has been updated to type, id, count and ctime
> to support holding multiple logs.
>
> Format of current variable name
>   dump-type0-1-2-12345678
>
>   type:0
>   id:1
>   count:2
>   ctime:12345678
>
> On the other hand, if an old variable name before being updated
> remains, users can't erase it via /dev/pstore.
>
> Format of old variable name
>   dump-type0-1-12345678
>
>   type:0
>   id:1
>   ctime:12345678
>
> [Solution]
>
> This patch adds a format check for the old variable name in a erase callback to make it erasable.
>
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
> ---
>  drivers/firmware/efivars.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
> index dd228d5..b1cd028 100644
> --- a/drivers/firmware/efivars.c
> +++ b/drivers/firmware/efivars.c
> @@ -777,6 +777,8 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
>         struct efivars *efivars = psi->data;
>         struct efivar_entry *entry, *found = NULL;
>         int i;
> +       unsigned int type_old, part_old;
> +       unsigned long time_old;
>
>         sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
>                 time.tv_sec);
> @@ -796,8 +798,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
>                 if (efi_guidcmp(entry->var.VendorGuid, vendor))
>                         continue;
>                 if (utf16_strncmp(entry->var.VariableName, efi_name,
> -                                 utf16_strlen(efi_name)))
> -                       continue;
> +                                 utf16_strlen(efi_name))) {
> +                       /*
> +                        * Check if an old format,
> +                        * which doesn't support holding
> +                        * multiple logs, remains.
> +                        */
> +                       if (sscanf(name, "dump-type%u-%u-%lu",
> +                                  &type_old, &part_old, &time_old) != 3)

This doesn't look right.  This should probably mirror the sprintf() at
the top of the function using a new string, convert it to 16-bit
Unicodeand then compare it like we do for the 4-variable version above
(please ignore the fact that this driver incorrectly calls these
strings utf16 everywhere -- that needs to be fixed).

> +                               continue;
> +               }
>
>                 /* found */
>                 found = entry;
> -- 1.7.1

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

* Re: [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
@ 2012-10-29 20:24   ` Mike Waychison
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Waychison @ 2012-10-29 20:24 UTC (permalink / raw)
  To: Seiji Aguchi
  Cc: linux-kernel, linux-efi, linux-acpi, Luck,
	Tony (tony.luck@intel.com), Matthew Garrett (mjg@redhat.com),
	dzickus, dle-develop, Satoru Moriya

On Fri, Oct 26, 2012 at 2:43 PM, Seiji Aguchi <seiji.aguchi@hds.com> wrote:
> [Issue]
>
> A format of variable name has been updated to type, id, count and ctime
> to support holding multiple logs.
>
> Format of current variable name
>   dump-type0-1-2-12345678
>
>   type:0
>   id:1
>   count:2
>   ctime:12345678
>
> On the other hand, if an old variable name before being updated
> remains, users can't erase it via /dev/pstore.
>
> Format of old variable name
>   dump-type0-1-12345678
>
>   type:0
>   id:1
>   ctime:12345678
>
> [Solution]
>
> This patch adds a format check for the old variable name in a erase callback to make it erasable.
>
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
> ---
>  drivers/firmware/efivars.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
> index dd228d5..b1cd028 100644
> --- a/drivers/firmware/efivars.c
> +++ b/drivers/firmware/efivars.c
> @@ -777,6 +777,8 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
>         struct efivars *efivars = psi->data;
>         struct efivar_entry *entry, *found = NULL;
>         int i;
> +       unsigned int type_old, part_old;
> +       unsigned long time_old;
>
>         sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
>                 time.tv_sec);
> @@ -796,8 +798,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
>                 if (efi_guidcmp(entry->var.VendorGuid, vendor))
>                         continue;
>                 if (utf16_strncmp(entry->var.VariableName, efi_name,
> -                                 utf16_strlen(efi_name)))
> -                       continue;
> +                                 utf16_strlen(efi_name))) {
> +                       /*
> +                        * Check if an old format,
> +                        * which doesn't support holding
> +                        * multiple logs, remains.
> +                        */
> +                       if (sscanf(name, "dump-type%u-%u-%lu",
> +                                  &type_old, &part_old, &time_old) != 3)

This doesn't look right.  This should probably mirror the sprintf() at
the top of the function using a new string, convert it to 16-bit
Unicodeand then compare it like we do for the 4-variable version above
(please ignore the fact that this driver incorrectly calls these
strings utf16 everywhere -- that needs to be fixed).

> +                               continue;
> +               }
>
>                 /* found */
>                 found = entry;
> -- 1.7.1

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

* RE: [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
  2012-10-29 20:24   ` Mike Waychison
@ 2012-10-29 20:40     ` Seiji Aguchi
  -1 siblings, 0 replies; 6+ messages in thread
From: Seiji Aguchi @ 2012-10-29 20:40 UTC (permalink / raw)
  To: Mike Waychison
  Cc: linux-kernel, linux-efi, linux-acpi, Luck,
	Tony (tony.luck@intel.com), Matthew Garrett (mjg@redhat.com),
	dzickus, dle-develop, Satoru Moriya

> > +                                 utf16_strlen(efi_name))) {
> > +                       /*
> > +                        * Check if an old format,
> > +                        * which doesn't support holding
> > +                        * multiple logs, remains.
> > +                        */
> > +                       if (sscanf(name, "dump-type%u-%u-%lu",
> > +                                  &type_old, &part_old, &time_old) !=
> > + 3)
> 
> This doesn't look right.  This should probably mirror the sprintf() at the top of the function using a new string, convert it to 16-bit
> Unicodeand then compare it like we do for the 4-variable version above (please ignore the fact that this driver incorrectly calls these
> strings utf16 everywhere -- that needs to be fixed).

I will fix it as well.

Seiji

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

* RE: [PATCH v3 7/7] Add a format check for an existing variable name at erasing time
@ 2012-10-29 20:40     ` Seiji Aguchi
  0 siblings, 0 replies; 6+ messages in thread
From: Seiji Aguchi @ 2012-10-29 20:40 UTC (permalink / raw)
  To: Mike Waychison
  Cc: linux-kernel, linux-efi, linux-acpi, Luck,
	Tony (tony.luck@intel.com), Matthew Garrett (mjg@redhat.com),
	dzickus, dle-develop, Satoru Moriya

> > +                                 utf16_strlen(efi_name))) {
> > +                       /*
> > +                        * Check if an old format,
> > +                        * which doesn't support holding
> > +                        * multiple logs, remains.
> > +                        */
> > +                       if (sscanf(name, "dump-type%u-%u-%lu",
> > +                                  &type_old, &part_old, &time_old) !=
> > + 3)
> 
> This doesn't look right.  This should probably mirror the sprintf() at the top of the function using a new string, convert it to 16-bit
> Unicodeand then compare it like we do for the 4-variable version above (please ignore the fact that this driver incorrectly calls these
> strings utf16 everywhere -- that needs to be fixed).

I will fix it as well.

Seiji

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

end of thread, other threads:[~2012-10-29 20:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 21:43 [PATCH v3 7/7] Add a format check for an existing variable name at erasing time Seiji Aguchi
2012-10-26 21:43 ` Seiji Aguchi
2012-10-29 20:24 ` Mike Waychison
2012-10-29 20:24   ` Mike Waychison
2012-10-29 20:40   ` Seiji Aguchi
2012-10-29 20:40     ` Seiji Aguchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.