diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-06 18:20:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-06 18:20:51 -0500 |
commit | dabe589657ad0f9a0d6f4101e2171574f74b00bf (patch) | |
tree | 60c1c779e316718f58dc4093a9585d980db2bdba | |
parent | 07eca14b6fdd0ccc52ed9127aa6924507261a907 (diff) | |
parent | 0b02e448a2ebb46eb9be4f1bdfc87112bd420cbf (diff) |
Merge branch 'efi-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull EFI fixes from Ingo Molnar:
"Misc fixes: world-readable pointer removal from sysfs, a ESRT kfree()
bug fix and a comment update"
* 'efi-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
efi: Add comment to avoid future expanding of sysfs systab
efi/esrt: Use memunmap() instead of kfree() to free the remapping
efi: Move some sysfs files to be read-only by root
-rw-r--r-- | drivers/firmware/efi/efi.c | 5 | ||||
-rw-r--r-- | drivers/firmware/efi/esrt.c | 17 | ||||
-rw-r--r-- | drivers/firmware/efi/runtime-map.c | 10 | ||||
-rw-r--r-- | include/linux/sysfs.h | 6 |
4 files changed, 21 insertions, 17 deletions
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index f70febf680c3..557a47829d03 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -109,6 +109,8 @@ struct kobject *efi_kobj; | |||
109 | /* | 109 | /* |
110 | * Let's not leave out systab information that snuck into | 110 | * Let's not leave out systab information that snuck into |
111 | * the efivars driver | 111 | * the efivars driver |
112 | * Note, do not add more fields in systab sysfs file as it breaks sysfs | ||
113 | * one value per file rule! | ||
112 | */ | 114 | */ |
113 | static ssize_t systab_show(struct kobject *kobj, | 115 | static ssize_t systab_show(struct kobject *kobj, |
114 | struct kobj_attribute *attr, char *buf) | 116 | struct kobj_attribute *attr, char *buf) |
@@ -143,8 +145,7 @@ static ssize_t systab_show(struct kobject *kobj, | |||
143 | return str - buf; | 145 | return str - buf; |
144 | } | 146 | } |
145 | 147 | ||
146 | static struct kobj_attribute efi_attr_systab = | 148 | static struct kobj_attribute efi_attr_systab = __ATTR_RO_MODE(systab, 0400); |
147 | __ATTR(systab, 0400, systab_show, NULL); | ||
148 | 149 | ||
149 | #define EFI_FIELD(var) efi.var | 150 | #define EFI_FIELD(var) efi.var |
150 | 151 | ||
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index bd7ed3c1148a..c47e0c6ec00f 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 = { | |||
106 | }; | 106 | }; |
107 | 107 | ||
108 | /* Generic ESRT Entry ("ESRE") support. */ | 108 | /* Generic ESRT Entry ("ESRE") support. */ |
109 | static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf) | 109 | static ssize_t fw_class_show(struct esre_entry *entry, char *buf) |
110 | { | 110 | { |
111 | char *str = buf; | 111 | char *str = buf; |
112 | 112 | ||
@@ -117,18 +117,16 @@ static ssize_t esre_fw_class_show(struct esre_entry *entry, char *buf) | |||
117 | return str - buf; | 117 | return str - buf; |
118 | } | 118 | } |
119 | 119 | ||
120 | static struct esre_attribute esre_fw_class = __ATTR(fw_class, 0400, | 120 | static struct esre_attribute esre_fw_class = __ATTR_RO_MODE(fw_class, 0400); |
121 | esre_fw_class_show, NULL); | ||
122 | 121 | ||
123 | #define esre_attr_decl(name, size, fmt) \ | 122 | #define esre_attr_decl(name, size, fmt) \ |
124 | static ssize_t esre_##name##_show(struct esre_entry *entry, char *buf) \ | 123 | static ssize_t name##_show(struct esre_entry *entry, char *buf) \ |
125 | { \ | 124 | { \ |
126 | return sprintf(buf, fmt "\n", \ | 125 | return sprintf(buf, fmt "\n", \ |
127 | le##size##_to_cpu(entry->esre.esre1->name)); \ | 126 | le##size##_to_cpu(entry->esre.esre1->name)); \ |
128 | } \ | 127 | } \ |
129 | \ | 128 | \ |
130 | static struct esre_attribute esre_##name = __ATTR(name, 0400, \ | 129 | static struct esre_attribute esre_##name = __ATTR_RO_MODE(name, 0400) |
131 | esre_##name##_show, NULL) | ||
132 | 130 | ||
133 | esre_attr_decl(fw_type, 32, "%u"); | 131 | esre_attr_decl(fw_type, 32, "%u"); |
134 | esre_attr_decl(fw_version, 32, "%u"); | 132 | esre_attr_decl(fw_version, 32, "%u"); |
@@ -193,14 +191,13 @@ static int esre_create_sysfs_entry(void *esre, int entry_num) | |||
193 | 191 | ||
194 | /* support for displaying ESRT fields at the top level */ | 192 | /* support for displaying ESRT fields at the top level */ |
195 | #define esrt_attr_decl(name, size, fmt) \ | 193 | #define esrt_attr_decl(name, size, fmt) \ |
196 | static ssize_t esrt_##name##_show(struct kobject *kobj, \ | 194 | static ssize_t name##_show(struct kobject *kobj, \ |
197 | struct kobj_attribute *attr, char *buf)\ | 195 | struct kobj_attribute *attr, char *buf)\ |
198 | { \ | 196 | { \ |
199 | return sprintf(buf, fmt "\n", le##size##_to_cpu(esrt->name)); \ | 197 | return sprintf(buf, fmt "\n", le##size##_to_cpu(esrt->name)); \ |
200 | } \ | 198 | } \ |
201 | \ | 199 | \ |
202 | static struct kobj_attribute esrt_##name = __ATTR(name, 0400, \ | 200 | static struct kobj_attribute esrt_##name = __ATTR_RO_MODE(name, 0400) |
203 | esrt_##name##_show, NULL) | ||
204 | 201 | ||
205 | esrt_attr_decl(fw_resource_count, 32, "%u"); | 202 | esrt_attr_decl(fw_resource_count, 32, "%u"); |
206 | esrt_attr_decl(fw_resource_count_max, 32, "%u"); | 203 | esrt_attr_decl(fw_resource_count_max, 32, "%u"); |
@@ -431,7 +428,7 @@ err_remove_group: | |||
431 | err_remove_esrt: | 428 | err_remove_esrt: |
432 | kobject_put(esrt_kobj); | 429 | kobject_put(esrt_kobj); |
433 | err: | 430 | err: |
434 | kfree(esrt); | 431 | memunmap(esrt); |
435 | esrt = NULL; | 432 | esrt = NULL; |
436 | return error; | 433 | return error; |
437 | } | 434 | } |
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, | |||
63 | return map_attr->show(entry, buf); | 63 | return map_attr->show(entry, buf); |
64 | } | 64 | } |
65 | 65 | ||
66 | static struct map_attribute map_type_attr = __ATTR_RO(type); | 66 | static struct map_attribute map_type_attr = __ATTR_RO_MODE(type, 0400); |
67 | static struct map_attribute map_phys_addr_attr = __ATTR_RO(phys_addr); | 67 | static struct map_attribute map_phys_addr_attr = __ATTR_RO_MODE(phys_addr, 0400); |
68 | static struct map_attribute map_virt_addr_attr = __ATTR_RO(virt_addr); | 68 | static struct map_attribute map_virt_addr_attr = __ATTR_RO_MODE(virt_addr, 0400); |
69 | static struct map_attribute map_num_pages_attr = __ATTR_RO(num_pages); | 69 | static struct map_attribute map_num_pages_attr = __ATTR_RO_MODE(num_pages, 0400); |
70 | static struct map_attribute map_attribute_attr = __ATTR_RO(attribute); | 70 | static struct map_attribute map_attribute_attr = __ATTR_RO_MODE(attribute, 0400); |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * These are default attributes that are added for every memmap entry. | 73 | * 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 { | |||
117 | .show = _name##_show, \ | 117 | .show = _name##_show, \ |
118 | } | 118 | } |
119 | 119 | ||
120 | #define __ATTR_RO_MODE(_name, _mode) { \ | ||
121 | .attr = { .name = __stringify(_name), \ | ||
122 | .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ | ||
123 | .show = _name##_show, \ | ||
124 | } | ||
125 | |||
120 | #define __ATTR_WO(_name) { \ | 126 | #define __ATTR_WO(_name) { \ |
121 | .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \ | 127 | .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \ |
122 | .store = _name##_store, \ | 128 | .store = _name##_store, \ |