hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/acpi/acpi_configfs.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ACPI configfs support
34 *
45 * Copyright (c) 2016 Intel Corporation
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
96 */
107
118 #define pr_fmt(fmt) "ACPI configfs: " fmt
....@@ -14,6 +11,7 @@
1411 #include <linux/module.h>
1512 #include <linux/configfs.h>
1613 #include <linux/acpi.h>
14
+#include <linux/security.h>
1715
1816 #include "acpica/accommon.h"
1917 #include "acpica/actables.h"
....@@ -31,7 +29,10 @@
3129 {
3230 const struct acpi_table_header *header = data;
3331 struct acpi_table *table;
34
- int ret;
32
+ int ret = security_locked_down(LOCKDOWN_ACPI_TABLES);
33
+
34
+ if (ret)
35
+ return ret;
3536
3637 table = container_of(cfg, struct acpi_table, cfg);
3738
....@@ -56,11 +57,7 @@
5657 if (!table->header)
5758 return -ENOMEM;
5859
59
- ACPI_INFO(("Host-directed Dynamic ACPI Table Load:"));
60
- ret = acpi_tb_install_and_load_table(
61
- ACPI_PTR_TO_PHYSADDR(table->header),
62
- ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE,
63
- &table->index);
60
+ ret = acpi_load_table(table->header, &table->index);
6461 if (ret) {
6562 kfree(table->header);
6663 table->header = NULL;
....@@ -97,22 +94,22 @@
9794
9895 CONFIGFS_BIN_ATTR(acpi_table_, aml, NULL, MAX_ACPI_TABLE_SIZE);
9996
100
-struct configfs_bin_attribute *acpi_table_bin_attrs[] = {
97
+static struct configfs_bin_attribute *acpi_table_bin_attrs[] = {
10198 &acpi_table_attr_aml,
10299 NULL,
103100 };
104101
105
-ssize_t acpi_table_signature_show(struct config_item *cfg, char *str)
102
+static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str)
106103 {
107104 struct acpi_table_header *h = get_header(cfg);
108105
109106 if (!h)
110107 return -EINVAL;
111108
112
- return sprintf(str, "%.*s\n", ACPI_NAME_SIZE, h->signature);
109
+ return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
113110 }
114111
115
-ssize_t acpi_table_length_show(struct config_item *cfg, char *str)
112
+static ssize_t acpi_table_length_show(struct config_item *cfg, char *str)
116113 {
117114 struct acpi_table_header *h = get_header(cfg);
118115
....@@ -122,7 +119,7 @@
122119 return sprintf(str, "%d\n", h->length);
123120 }
124121
125
-ssize_t acpi_table_revision_show(struct config_item *cfg, char *str)
122
+static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str)
126123 {
127124 struct acpi_table_header *h = get_header(cfg);
128125
....@@ -132,7 +129,7 @@
132129 return sprintf(str, "%d\n", h->revision);
133130 }
134131
135
-ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str)
132
+static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str)
136133 {
137134 struct acpi_table_header *h = get_header(cfg);
138135
....@@ -142,7 +139,7 @@
142139 return sprintf(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
143140 }
144141
145
-ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str)
142
+static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str)
146143 {
147144 struct acpi_table_header *h = get_header(cfg);
148145
....@@ -152,7 +149,7 @@
152149 return sprintf(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
153150 }
154151
155
-ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str)
152
+static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str)
156153 {
157154 struct acpi_table_header *h = get_header(cfg);
158155
....@@ -162,18 +159,19 @@
162159 return sprintf(str, "%d\n", h->oem_revision);
163160 }
164161
165
-ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, char *str)
162
+static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg,
163
+ char *str)
166164 {
167165 struct acpi_table_header *h = get_header(cfg);
168166
169167 if (!h)
170168 return -EINVAL;
171169
172
- return sprintf(str, "%.*s\n", ACPI_NAME_SIZE, h->asl_compiler_id);
170
+ return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
173171 }
174172
175
-ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg,
176
- char *str)
173
+static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg,
174
+ char *str)
177175 {
178176 struct acpi_table_header *h = get_header(cfg);
179177
....@@ -192,7 +190,7 @@
192190 CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_id);
193191 CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_revision);
194192
195
-struct configfs_attribute *acpi_table_attrs[] = {
193
+static struct configfs_attribute *acpi_table_attrs[] = {
196194 &acpi_table_attr_signature,
197195 &acpi_table_attr_length,
198196 &acpi_table_attr_revision,
....@@ -229,10 +227,11 @@
229227 struct acpi_table *table = container_of(cfg, struct acpi_table, cfg);
230228
231229 ACPI_INFO(("Host-directed Dynamic ACPI Table Unload"));
232
- acpi_tb_unload_table(table->index);
230
+ acpi_unload_table(table->index);
231
+ config_item_put(cfg);
233232 }
234233
235
-struct configfs_group_operations acpi_table_group_ops = {
234
+static struct configfs_group_operations acpi_table_group_ops = {
236235 .make_item = acpi_table_make_item,
237236 .drop_item = acpi_table_drop_item,
238237 };