All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL 0/3] EFI fixes for v4.15
@ 2017-12-06  9:50 ` Ard Biesheuvel
  0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Ard Biesheuvel, linux-kernel, Dave Young, Greg Kroah-Hartman,
	Linus Torvalds, Matt Fleming, Pan Bian

The following changes since commit ae64f9bd1d3621b5e60d7363bc20afb46aede215:

  Linux 4.15-rc2 (2017-12-03 11:01:47 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git efi-urgent

for you to fetch changes up to bfe89df500c99e29fbd0fd6f18e396f1625efcee:

  efi: add comment to avoid future expanding of sysfs systab (2017-12-05 18:11:36 +0000)

----------------------------------------------------------------
A couple of fixes for v4.15:
- limit the permissions of EFI related sysfs nodes to 0400
- use memunmap not kfree for a mapping created with memremap
- add a comment to the code that produces the contents of
  /sys/firmware/efi/systab that it already violates policy, and
  no new entries should be added to it

----------------------------------------------------------------
Dave Young (1):
      efi: add comment to avoid future expanding of sysfs systab

Greg Kroah-Hartman (1):
      efi: move some sysfs files to be read-only by root

Pan Bian (1):
      efi/esrt: use memunmap rather kfree to free the remapping

 drivers/firmware/efi/efi.c         |  5 +++--
 drivers/firmware/efi/esrt.c        | 17 +++++++----------
 drivers/firmware/efi/runtime-map.c | 10 +++++-----
 include/linux/sysfs.h              |  6 ++++++
 4 files changed, 21 insertions(+), 17 deletions(-)

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

* [GIT PULL 0/3] EFI fixes for v4.15
@ 2017-12-06  9:50 ` Ard Biesheuvel
  0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar, Thomas Gleixner,
	H . Peter Anvin
  Cc: Ard Biesheuvel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dave Young,
	Greg Kroah-Hartman, Linus Torvalds, Matt Fleming, Pan Bian

The following changes since commit ae64f9bd1d3621b5e60d7363bc20afb46aede215:

  Linux 4.15-rc2 (2017-12-03 11:01:47 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git efi-urgent

for you to fetch changes up to bfe89df500c99e29fbd0fd6f18e396f1625efcee:

  efi: add comment to avoid future expanding of sysfs systab (2017-12-05 18:11:36 +0000)

----------------------------------------------------------------
A couple of fixes for v4.15:
- limit the permissions of EFI related sysfs nodes to 0400
- use memunmap not kfree for a mapping created with memremap
- add a comment to the code that produces the contents of
  /sys/firmware/efi/systab that it already violates policy, and
  no new entries should be added to it

----------------------------------------------------------------
Dave Young (1):
      efi: add comment to avoid future expanding of sysfs systab

Greg Kroah-Hartman (1):
      efi: move some sysfs files to be read-only by root

Pan Bian (1):
      efi/esrt: use memunmap rather kfree to free the remapping

 drivers/firmware/efi/efi.c         |  5 +++--
 drivers/firmware/efi/esrt.c        | 17 +++++++----------
 drivers/firmware/efi/runtime-map.c | 10 +++++-----
 include/linux/sysfs.h              |  6 ++++++
 4 files changed, 21 insertions(+), 17 deletions(-)

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

* [PATCH 1/3] efi: move some sysfs files to be read-only by root
  2017-12-06  9:50 ` Ard Biesheuvel
  (?)
@ 2017-12-06  9:50 ` Ard Biesheuvel
  2017-12-06 20:29   ` [tip:efi/urgent] efi: Move " tip-bot for Greg Kroah-Hartman
  -1 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Greg Kroah-Hartman, Ard Biesheuvel, linux-kernel, Matt Fleming, stable

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thanks to the scripts/leaking_addresses.pl script, it was found that
some EFI values should not be readable by non-root users.

So make them root-only, and to do that, add a __ATTR_RO_MODE() macro to
make this easier, and use it in other places at the same time.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Dave Young <dyoung@redhat.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/efi.c         |  3 +--
 drivers/firmware/efi/esrt.c        | 15 ++++++---------
 drivers/firmware/efi/runtime-map.c | 10 +++++-----
 include/linux/sysfs.h              |  6 ++++++
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index f70febf680c3..c3eefa126e3b 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -143,8 +143,7 @@ static ssize_t systab_show(struct kobject *kobj,
 	return str - buf;
 }
 
-static struct kobj_attribute efi_attr_systab =
-			__ATTR(systab, 0400, systab_show, NULL);
+static struct kobj_attribute efi_attr_systab = __ATTR_RO_MODE(systab, 0400);
 
 #define EFI_FIELD(var) efi.var
 
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index bd7ed3c1148a..7aae2483fcb9 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -106,7 +106,7 @@ static const struct sysfs_ops esre_attr_ops = {
 };
 
 /* Generic ESRT Entry ("ESRE") support. */
-static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf)
+static ssize_t fw_class_show(struct esre_entry *entry, char *buf)
 {
 	char *str = buf;
 
@@ -117,18 +117,16 @@ static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf)
 	return str - buf;
 }
 
-static struct esre_attribute esre_fw_class = __ATTR(fw_class, 0400,
-	esre_fw_class_show, NULL);
+static struct esre_attribute esre_fw_class = __ATTR_RO_MODE(fw_class, 0400);
 
 #define esre_attr_decl(name, size, fmt) \
-static ssize_t esre_##name##_show(struct esre_entry *entry, char *buf) \
+static ssize_t name##_show(struct esre_entry *entry, char *buf) \
 { \
 	return sprintf(buf, fmt "\n", \
 		       le##size##_to_cpu(entry->esre.esre1->name)); \
 } \
 \
-static struct esre_attribute esre_##name = __ATTR(name, 0400, \
-	esre_##name##_show, NULL)
+static struct esre_attribute esre_##name = __ATTR_RO_MODE(name, 0400)
 
 esre_attr_decl(fw_type, 32, "%u");
 esre_attr_decl(fw_version, 32, "%u");
@@ -193,14 +191,13 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
 
 /* support for displaying ESRT fields at the top level */
 #define esrt_attr_decl(name, size, fmt) \
-static ssize_t esrt_##name##_show(struct kobject *kobj, \
+static ssize_t name##_show(struct kobject *kobj, \
 				  struct kobj_attribute *attr, char *buf)\
 { \
 	return sprintf(buf, fmt "\n", le##size##_to_cpu(esrt->name)); \
 } \
 \
-static struct kobj_attribute esrt_##name = __ATTR(name, 0400, \
-	esrt_##name##_show, NULL)
+static struct kobj_attribute esrt_##name = __ATTR_RO_MODE(name, 0400)
 
 esrt_attr_decl(fw_resource_count, 32, "%u");
 esrt_attr_decl(fw_resource_count_max, 32, "%u");
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index 8e64b77aeac9..f377609ff141 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -63,11 +63,11 @@ static ssize_t map_attr_show(struct kobject *kobj, struct attribute *attr,
 	return map_attr->show(entry, buf);
 }
 
-static struct map_attribute map_type_attr = __ATTR_RO(type);
-static struct map_attribute map_phys_addr_attr   = __ATTR_RO(phys_addr);
-static struct map_attribute map_virt_addr_attr  = __ATTR_RO(virt_addr);
-static struct map_attribute map_num_pages_attr  = __ATTR_RO(num_pages);
-static struct map_attribute map_attribute_attr  = __ATTR_RO(attribute);
+static struct map_attribute map_type_attr = __ATTR_RO_MODE(type, 0400);
+static struct map_attribute map_phys_addr_attr = __ATTR_RO_MODE(phys_addr, 0400);
+static struct map_attribute map_virt_addr_attr = __ATTR_RO_MODE(virt_addr, 0400);
+static struct map_attribute map_num_pages_attr = __ATTR_RO_MODE(num_pages, 0400);
+static struct map_attribute map_attribute_attr = __ATTR_RO_MODE(attribute, 0400);
 
 /*
  * These are default attributes that are added for every memmap entry.
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index e32dfe098e82..40839c02d28c 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -117,6 +117,12 @@ struct attribute_group {
 	.show	= _name##_show,						\
 }
 
+#define __ATTR_RO_MODE(_name, _mode) {					\
+	.attr	= { .name = __stringify(_name),				\
+		    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
+	.show	= _name##_show,						\
+}
+
 #define __ATTR_WO(_name) {						\
 	.attr	= { .name = __stringify(_name), .mode = S_IWUSR },	\
 	.store	= _name##_store,					\
-- 
2.11.0

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

* [PATCH 2/3] efi/esrt: use memunmap rather kfree to free the remapping
  2017-12-06  9:50 ` Ard Biesheuvel
  (?)
  (?)
@ 2017-12-06  9:50 ` Ard Biesheuvel
  2017-12-06 20:30   ` [tip:efi/urgent] efi/esrt: Use memunmap() instead of kfree() " tip-bot for Pan Bian
  -1 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Pan Bian, Ard Biesheuvel, linux-kernel, Matt Fleming, stable

From: Pan Bian <bianpan2016@163.com>

The remapping result of memremap should be freed with memunmap, not
kfree.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/esrt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index 7aae2483fcb9..c47e0c6ec00f 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -428,7 +428,7 @@ static int __init esrt_sysfs_init(void)
 err_remove_esrt:
 	kobject_put(esrt_kobj);
 err:
-	kfree(esrt);
+	memunmap(esrt);
 	esrt = NULL;
 	return error;
 }
-- 
2.11.0

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

* [PATCH 3/3] efi: add comment to avoid future expanding of sysfs systab
@ 2017-12-06  9:50   ` Ard Biesheuvel
  0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Dave Young, Ard Biesheuvel, linux-kernel, Matt Fleming

From: Dave Young <dyoung@redhat.com>

/sys/firmware/efi/systab shows several different values, it breaks sysfs
one file one value design.  But since there are already userspace tools
depend on it eg. kexec-tools so add code comment to alert future expanding
of this file.

Signed-off-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/efi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index c3eefa126e3b..557a47829d03 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -109,6 +109,8 @@ struct kobject *efi_kobj;
 /*
  * Let's not leave out systab information that snuck into
  * the efivars driver
+ * Note, do not add more fields in systab sysfs file as it breaks sysfs
+ * one value per file rule!
  */
 static ssize_t systab_show(struct kobject *kobj,
 			   struct kobj_attribute *attr, char *buf)
-- 
2.11.0

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

* [PATCH 3/3] efi: add comment to avoid future expanding of sysfs systab
@ 2017-12-06  9:50   ` Ard Biesheuvel
  0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2017-12-06  9:50 UTC (permalink / raw)
  To: linux-efi-u79uwXL29TY76Z2rM5mHXA, Ingo Molnar, Thomas Gleixner,
	H . Peter Anvin
  Cc: Dave Young, Ard Biesheuvel, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	Matt Fleming

From: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

/sys/firmware/efi/systab shows several different values, it breaks sysfs
one file one value design.  But since there are already userspace tools
depend on it eg. kexec-tools so add code comment to alert future expanding
of this file.

Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Cc: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/firmware/efi/efi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index c3eefa126e3b..557a47829d03 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -109,6 +109,8 @@ struct kobject *efi_kobj;
 /*
  * Let's not leave out systab information that snuck into
  * the efivars driver
+ * Note, do not add more fields in systab sysfs file as it breaks sysfs
+ * one value per file rule!
  */
 static ssize_t systab_show(struct kobject *kobj,
 			   struct kobj_attribute *attr, char *buf)
-- 
2.11.0

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

* Re: [GIT PULL 0/3] EFI fixes for v4.15
@ 2017-12-06 17:20   ` Ingo Molnar
  0 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2017-12-06 17:20 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Thomas Gleixner, H . Peter Anvin, linux-kernel,
	Dave Young, Greg Kroah-Hartman, Linus Torvalds, Matt Fleming,
	Pan Bian


* Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> The following changes since commit ae64f9bd1d3621b5e60d7363bc20afb46aede215:
> 
>   Linux 4.15-rc2 (2017-12-03 11:01:47 -0500)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git efi-urgent
> 
> for you to fetch changes up to bfe89df500c99e29fbd0fd6f18e396f1625efcee:
> 
>   efi: add comment to avoid future expanding of sysfs systab (2017-12-05 18:11:36 +0000)
> 
> ----------------------------------------------------------------
> A couple of fixes for v4.15:
> - limit the permissions of EFI related sysfs nodes to 0400
> - use memunmap not kfree for a mapping created with memremap
> - add a comment to the code that produces the contents of
>   /sys/firmware/efi/systab that it already violates policy, and
>   no new entries should be added to it
> 
> ----------------------------------------------------------------
> Dave Young (1):
>       efi: add comment to avoid future expanding of sysfs systab
> 
> Greg Kroah-Hartman (1):
>       efi: move some sysfs files to be read-only by root
> 
> Pan Bian (1):
>       efi/esrt: use memunmap rather kfree to free the remapping
> 
>  drivers/firmware/efi/efi.c         |  5 +++--
>  drivers/firmware/efi/esrt.c        | 17 +++++++----------
>  drivers/firmware/efi/runtime-map.c | 10 +++++-----
>  include/linux/sysfs.h              |  6 ++++++
>  4 files changed, 21 insertions(+), 17 deletions(-)

Applied, thanks Ard!

	Ingo

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

* Re: [GIT PULL 0/3] EFI fixes for v4.15
@ 2017-12-06 17:20   ` Ingo Molnar
  0 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2017-12-06 17:20 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	H . Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dave Young,
	Greg Kroah-Hartman, Linus Torvalds, Matt Fleming, Pan Bian


* Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:

> The following changes since commit ae64f9bd1d3621b5e60d7363bc20afb46aede215:
> 
>   Linux 4.15-rc2 (2017-12-03 11:01:47 -0500)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git efi-urgent
> 
> for you to fetch changes up to bfe89df500c99e29fbd0fd6f18e396f1625efcee:
> 
>   efi: add comment to avoid future expanding of sysfs systab (2017-12-05 18:11:36 +0000)
> 
> ----------------------------------------------------------------
> A couple of fixes for v4.15:
> - limit the permissions of EFI related sysfs nodes to 0400
> - use memunmap not kfree for a mapping created with memremap
> - add a comment to the code that produces the contents of
>   /sys/firmware/efi/systab that it already violates policy, and
>   no new entries should be added to it
> 
> ----------------------------------------------------------------
> Dave Young (1):
>       efi: add comment to avoid future expanding of sysfs systab
> 
> Greg Kroah-Hartman (1):
>       efi: move some sysfs files to be read-only by root
> 
> Pan Bian (1):
>       efi/esrt: use memunmap rather kfree to free the remapping
> 
>  drivers/firmware/efi/efi.c         |  5 +++--
>  drivers/firmware/efi/esrt.c        | 17 +++++++----------
>  drivers/firmware/efi/runtime-map.c | 10 +++++-----
>  include/linux/sysfs.h              |  6 ++++++
>  4 files changed, 21 insertions(+), 17 deletions(-)

Applied, thanks Ard!

	Ingo

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

* [tip:efi/urgent] efi: Move some sysfs files to be read-only by root
  2017-12-06  9:50 ` [PATCH 1/3] efi: move some sysfs files to be read-only by root Ard Biesheuvel
@ 2017-12-06 20:29   ` tip-bot for Greg Kroah-Hartman
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Greg Kroah-Hartman @ 2017-12-06 20:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, linux-kernel, hpa, stable, gregkh, tglx, torvalds,
	ard.biesheuvel, matt, peterz, dyoung

Commit-ID:  af97a77bc01ce49a466f9d4c0125479e2e2230b6
Gitweb:     https://git.kernel.org/tip/af97a77bc01ce49a466f9d4c0125479e2e2230b6
Author:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
AuthorDate: Wed, 6 Dec 2017 09:50:08 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 6 Dec 2017 19:31:39 +0100

efi: Move some sysfs files to be read-only by root

Thanks to the scripts/leaking_addresses.pl script, it was found that
some EFI values should not be readable by non-root users.

So make them root-only, and to do that, add a __ATTR_RO_MODE() macro to
make this easier, and use it in other places at the same time.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Cc: stable <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/20171206095010.24170-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/efi.c         |  3 +--
 drivers/firmware/efi/esrt.c        | 15 ++++++---------
 drivers/firmware/efi/runtime-map.c | 10 +++++-----
 include/linux/sysfs.h              |  6 ++++++
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index f70febf..c3eefa1 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -143,8 +143,7 @@ static ssize_t systab_show(struct kobject *kobj,
 	return str - buf;
 }
 
-static struct kobj_attribute efi_attr_systab =
-			__ATTR(systab, 0400, systab_show, NULL);
+static struct kobj_attribute efi_attr_systab = __ATTR_RO_MODE(systab, 0400);
 
 #define EFI_FIELD(var) efi.var
 
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index bd7ed3c..7aae248 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -106,7 +106,7 @@ static const struct sysfs_ops esre_attr_ops = {
 };
 
 /* Generic ESRT Entry ("ESRE") support. */
-static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf)
+static ssize_t fw_class_show(struct esre_entry *entry, char *buf)
 {
 	char *str = buf;
 
@@ -117,18 +117,16 @@ static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf)
 	return str - buf;
 }
 
-static struct esre_attribute esre_fw_class = __ATTR(fw_class, 0400,
-	esre_fw_class_show, NULL);
+static struct esre_attribute esre_fw_class = __ATTR_RO_MODE(fw_class, 0400);
 
 #define esre_attr_decl(name, size, fmt) \
-static ssize_t esre_##name##_show(struct esre_entry *entry, char *buf) \
+static ssize_t name##_show(struct esre_entry *entry, char *buf) \
 { \
 	return sprintf(buf, fmt "\n", \
 		       le##size##_to_cpu(entry->esre.esre1->name)); \
 } \
 \
-static struct esre_attribute esre_##name = __ATTR(name, 0400, \
-	esre_##name##_show, NULL)
+static struct esre_attribute esre_##name = __ATTR_RO_MODE(name, 0400)
 
 esre_attr_decl(fw_type, 32, "%u");
 esre_attr_decl(fw_version, 32, "%u");
@@ -193,14 +191,13 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
 
 /* support for displaying ESRT fields at the top level */
 #define esrt_attr_decl(name, size, fmt) \
-static ssize_t esrt_##name##_show(struct kobject *kobj, \
+static ssize_t name##_show(struct kobject *kobj, \
 				  struct kobj_attribute *attr, char *buf)\
 { \
 	return sprintf(buf, fmt "\n", le##size##_to_cpu(esrt->name)); \
 } \
 \
-static struct kobj_attribute esrt_##name = __ATTR(name, 0400, \
-	esrt_##name##_show, NULL)
+static struct kobj_attribute esrt_##name = __ATTR_RO_MODE(name, 0400)
 
 esrt_attr_decl(fw_resource_count, 32, "%u");
 esrt_attr_decl(fw_resource_count_max, 32, "%u");
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index 8e64b77..f377609 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -63,11 +63,11 @@ static ssize_t map_attr_show(struct kobject *kobj, struct attribute *attr,
 	return map_attr->show(entry, buf);
 }
 
-static struct map_attribute map_type_attr = __ATTR_RO(type);
-static struct map_attribute map_phys_addr_attr   = __ATTR_RO(phys_addr);
-static struct map_attribute map_virt_addr_attr  = __ATTR_RO(virt_addr);
-static struct map_attribute map_num_pages_attr  = __ATTR_RO(num_pages);
-static struct map_attribute map_attribute_attr  = __ATTR_RO(attribute);
+static struct map_attribute map_type_attr = __ATTR_RO_MODE(type, 0400);
+static struct map_attribute map_phys_addr_attr = __ATTR_RO_MODE(phys_addr, 0400);
+static struct map_attribute map_virt_addr_attr = __ATTR_RO_MODE(virt_addr, 0400);
+static struct map_attribute map_num_pages_attr = __ATTR_RO_MODE(num_pages, 0400);
+static struct map_attribute map_attribute_attr = __ATTR_RO_MODE(attribute, 0400);
 
 /*
  * These are default attributes that are added for every memmap entry.
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index e32dfe0..40839c0 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -117,6 +117,12 @@ struct attribute_group {
 	.show	= _name##_show,						\
 }
 
+#define __ATTR_RO_MODE(_name, _mode) {					\
+	.attr	= { .name = __stringify(_name),				\
+		    .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },		\
+	.show	= _name##_show,						\
+}
+
 #define __ATTR_WO(_name) {						\
 	.attr	= { .name = __stringify(_name), .mode = S_IWUSR },	\
 	.store	= _name##_store,					\

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

* [tip:efi/urgent] efi/esrt: Use memunmap() instead of kfree() to free the remapping
  2017-12-06  9:50 ` [PATCH 2/3] efi/esrt: use memunmap rather kfree to free the remapping Ard Biesheuvel
@ 2017-12-06 20:30   ` tip-bot for Pan Bian
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Pan Bian @ 2017-12-06 20:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, linux-kernel, ard.biesheuvel, mingo, bianpan2016,
	torvalds, peterz, stable, matt

Commit-ID:  89c5a2d34bda58319e3075e8e7dd727ea25a435c
Gitweb:     https://git.kernel.org/tip/89c5a2d34bda58319e3075e8e7dd727ea25a435c
Author:     Pan Bian <bianpan2016@163.com>
AuthorDate: Wed, 6 Dec 2017 09:50:09 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 6 Dec 2017 19:32:08 +0100

efi/esrt: Use memunmap() instead of kfree() to free the remapping

The remapping result of memremap() should be freed with memunmap(), not kfree().

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: <stable@vger.kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20171206095010.24170-3-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/esrt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index 7aae248..c47e0c6 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -428,7 +428,7 @@ err_remove_group:
 err_remove_esrt:
 	kobject_put(esrt_kobj);
 err:
-	kfree(esrt);
+	memunmap(esrt);
 	esrt = NULL;
 	return error;
 }

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

* [tip:efi/urgent] efi: Add comment to avoid future expanding of sysfs systab
  2017-12-06  9:50   ` Ard Biesheuvel
  (?)
@ 2017-12-06 20:30   ` tip-bot for Dave Young
  -1 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Dave Young @ 2017-12-06 20:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, ard.biesheuvel, gregkh, peterz, mingo, linux-kernel,
	torvalds, matt, hpa, dyoung

Commit-ID:  0b02e448a2ebb46eb9be4f1bdfc87112bd420cbf
Gitweb:     https://git.kernel.org/tip/0b02e448a2ebb46eb9be4f1bdfc87112bd420cbf
Author:     Dave Young <dyoung@redhat.com>
AuthorDate: Wed, 6 Dec 2017 09:50:10 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 6 Dec 2017 19:32:23 +0100

efi: Add comment to avoid future expanding of sysfs systab

/sys/firmware/efi/systab shows several different values, it breaks sysfs
one file one value design.  But since there are already userspace tools
depend on it eg. kexec-tools so add code comment to alert future expanding
of this file.

Signed-off-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20171206095010.24170-4-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/efi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index c3eefa1..557a478 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -109,6 +109,8 @@ struct kobject *efi_kobj;
 /*
  * Let's not leave out systab information that snuck into
  * the efivars driver
+ * Note, do not add more fields in systab sysfs file as it breaks sysfs
+ * one value per file rule!
  */
 static ssize_t systab_show(struct kobject *kobj,
 			   struct kobj_attribute *attr, char *buf)

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

end of thread, other threads:[~2017-12-06 20:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06  9:50 [GIT PULL 0/3] EFI fixes for v4.15 Ard Biesheuvel
2017-12-06  9:50 ` Ard Biesheuvel
2017-12-06  9:50 ` [PATCH 1/3] efi: move some sysfs files to be read-only by root Ard Biesheuvel
2017-12-06 20:29   ` [tip:efi/urgent] efi: Move " tip-bot for Greg Kroah-Hartman
2017-12-06  9:50 ` [PATCH 2/3] efi/esrt: use memunmap rather kfree to free the remapping Ard Biesheuvel
2017-12-06 20:30   ` [tip:efi/urgent] efi/esrt: Use memunmap() instead of kfree() " tip-bot for Pan Bian
2017-12-06  9:50 ` [PATCH 3/3] efi: add comment to avoid future expanding of sysfs systab Ard Biesheuvel
2017-12-06  9:50   ` Ard Biesheuvel
2017-12-06 20:30   ` [tip:efi/urgent] efi: Add " tip-bot for Dave Young
2017-12-06 17:20 ` [GIT PULL 0/3] EFI fixes for v4.15 Ingo Molnar
2017-12-06 17:20   ` Ingo Molnar

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.