summaryrefslogtreecommitdiff
path: root/drivers/firmware/google
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2024-12-15 15:49:09 +0100
committerTzung-Bi Shih <tzungbi@kernel.org>2024-12-17 03:59:31 +0000
commitbf2066caee80c1612cb5a3356dc16a7a298f58ab (patch)
tree6bcd0f8d6bdc41900a910e4af4faa189b45d2291 /drivers/firmware/google
parent40384c840ea1944d7c5a392e8975ed088ecf0b37 (diff)
firmware: google: cbmem: Constify 'struct bin_attribute'
The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Brian Norris <briannorris@chromium.org> Link: https://lore.kernel.org/r/20241215-sysfs-const-bin_attr-google-v1-1-e5c2808f5833@weissschuh.net Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'drivers/firmware/google')
-rw-r--r--drivers/firmware/google/cbmem.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/firmware/google/cbmem.c b/drivers/firmware/google/cbmem.c
index 66042160b361..773d05078e0a 100644
--- a/drivers/firmware/google/cbmem.c
+++ b/drivers/firmware/google/cbmem.c
@@ -30,7 +30,7 @@ static struct cbmem_entry *to_cbmem_entry(struct kobject *kobj)
}
static ssize_t mem_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf, loff_t pos,
+ const struct bin_attribute *bin_attr, char *buf, loff_t pos,
size_t count)
{
struct cbmem_entry *entry = to_cbmem_entry(kobj);
@@ -40,7 +40,7 @@ static ssize_t mem_read(struct file *filp, struct kobject *kobj,
}
static ssize_t mem_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr, char *buf, loff_t pos,
+ const struct bin_attribute *bin_attr, char *buf, loff_t pos,
size_t count)
{
struct cbmem_entry *entry = to_cbmem_entry(kobj);
@@ -53,7 +53,7 @@ static ssize_t mem_write(struct file *filp, struct kobject *kobj,
memcpy(entry->mem_file_buf + pos, buf, count);
return count;
}
-static BIN_ATTR_ADMIN_RW(mem, 0);
+static const BIN_ATTR_ADMIN_RW(mem, 0);
static ssize_t address_show(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -79,14 +79,14 @@ static struct attribute *attrs[] = {
NULL,
};
-static struct bin_attribute *bin_attrs[] = {
+static const struct bin_attribute *const bin_attrs[] = {
&bin_attr_mem,
NULL,
};
static const struct attribute_group cbmem_entry_group = {
.attrs = attrs,
- .bin_attrs = bin_attrs,
+ .bin_attrs_new = bin_attrs,
};
static const struct attribute_group *dev_groups[] = {