Skip to content

Commit 80f756c

Browse files
t-8chgregkh
authored andcommitted
firmware: qemu_fw_cfg: 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 <[email protected]> Acked-by: Gabriel Somlo <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Link: https://lore.kernel.org/r/20250114-sysfs-const-bin_attr-qemu_fw_cfg-v1-1-76f525a3ee72@weissschuh.net Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4aad348 commit 80f756c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/firmware/qemu_fw_cfg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
460460

461461
/* raw-read method and attribute */
462462
static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
463-
struct bin_attribute *bin_attr,
463+
const struct bin_attribute *bin_attr,
464464
char *buf, loff_t pos, size_t count)
465465
{
466466
struct fw_cfg_sysfs_entry *entry = to_entry(kobj);
@@ -474,9 +474,9 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
474474
return fw_cfg_read_blob(entry->select, buf, pos, count);
475475
}
476476

477-
static struct bin_attribute fw_cfg_sysfs_attr_raw = {
477+
static const struct bin_attribute fw_cfg_sysfs_attr_raw = {
478478
.attr = { .name = "raw", .mode = S_IRUSR },
479-
.read = fw_cfg_sysfs_read_raw,
479+
.read_new = fw_cfg_sysfs_read_raw,
480480
};
481481

482482
/*

0 commit comments

Comments
 (0)