* [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute'
@ 2025-01-14 21:50 Thomas Weißschuh
2025-01-15 19:39 ` Gabriel L. Somlo
2025-01-16 8:15 ` Michael S. Tsirkin
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2025-01-14 21:50 UTC (permalink / raw)
To: Gabriel Somlo, Michael S. Tsirkin
Cc: qemu-devel, linux-kernel, Thomas Weißschuh
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>
---
drivers/firmware/qemu_fw_cfg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index d58da3e4500a5e230b7da9a75e4d70df7c38c542..2615fb780e3c4500db36d4746880455f05479f1f 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -460,7 +460,7 @@ static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
/* raw-read method and attribute */
static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
+ const struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t count)
{
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,
return fw_cfg_read_blob(entry->select, buf, pos, count);
}
-static struct bin_attribute fw_cfg_sysfs_attr_raw = {
+static const struct bin_attribute fw_cfg_sysfs_attr_raw = {
.attr = { .name = "raw", .mode = S_IRUSR },
- .read = fw_cfg_sysfs_read_raw,
+ .read_new = fw_cfg_sysfs_read_raw,
};
/*
---
base-commit: 7f5b6a8ec18e3add4c74682f60b90c31bdf849f2
change-id: 20250114-sysfs-const-bin_attr-qemu_fw_cfg-fa4a95934904
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute'
2025-01-14 21:50 [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute' Thomas Weißschuh
@ 2025-01-15 19:39 ` Gabriel L. Somlo
2025-01-16 8:15 ` Michael S. Tsirkin
1 sibling, 0 replies; 3+ messages in thread
From: Gabriel L. Somlo @ 2025-01-15 19:39 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Michael S. Tsirkin, qemu-devel, linux-kernel
On Tue, Jan 14, 2025 at 10:50:20PM +0100, Thomas Weißschuh wrote:
> 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: Gabriel Somlo <somlo@cmu.edu>
Thanks,
--Gabriel
> ---
> drivers/firmware/qemu_fw_cfg.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index d58da3e4500a5e230b7da9a75e4d70df7c38c542..2615fb780e3c4500db36d4746880455f05479f1f 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -460,7 +460,7 @@ static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
>
> /* raw-read method and attribute */
> static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr,
> + const struct bin_attribute *bin_attr,
> char *buf, loff_t pos, size_t count)
> {
> 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,
> return fw_cfg_read_blob(entry->select, buf, pos, count);
> }
>
> -static struct bin_attribute fw_cfg_sysfs_attr_raw = {
> +static const struct bin_attribute fw_cfg_sysfs_attr_raw = {
> .attr = { .name = "raw", .mode = S_IRUSR },
> - .read = fw_cfg_sysfs_read_raw,
> + .read_new = fw_cfg_sysfs_read_raw,
> };
>
> /*
>
> ---
> base-commit: 7f5b6a8ec18e3add4c74682f60b90c31bdf849f2
> change-id: 20250114-sysfs-const-bin_attr-qemu_fw_cfg-fa4a95934904
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute'
2025-01-14 21:50 [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute' Thomas Weißschuh
2025-01-15 19:39 ` Gabriel L. Somlo
@ 2025-01-16 8:15 ` Michael S. Tsirkin
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2025-01-16 8:15 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Gabriel Somlo, qemu-devel, linux-kernel
On Tue, Jan 14, 2025 at 10:50:20PM +0100, Thomas Weißschuh wrote:
> 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>
why not
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/firmware/qemu_fw_cfg.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index d58da3e4500a5e230b7da9a75e4d70df7c38c542..2615fb780e3c4500db36d4746880455f05479f1f 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -460,7 +460,7 @@ static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
>
> /* raw-read method and attribute */
> static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *bin_attr,
> + const struct bin_attribute *bin_attr,
> char *buf, loff_t pos, size_t count)
> {
> 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,
> return fw_cfg_read_blob(entry->select, buf, pos, count);
> }
>
> -static struct bin_attribute fw_cfg_sysfs_attr_raw = {
> +static const struct bin_attribute fw_cfg_sysfs_attr_raw = {
> .attr = { .name = "raw", .mode = S_IRUSR },
> - .read = fw_cfg_sysfs_read_raw,
> + .read_new = fw_cfg_sysfs_read_raw,
> };
>
> /*
>
> ---
> base-commit: 7f5b6a8ec18e3add4c74682f60b90c31bdf849f2
> change-id: 20250114-sysfs-const-bin_attr-qemu_fw_cfg-fa4a95934904
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-16 8:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 21:50 [PATCH] firmware: qemu_fw_cfg: constify 'struct bin_attribute' Thomas Weißschuh
2025-01-15 19:39 ` Gabriel L. Somlo
2025-01-16 8:15 ` Michael S. Tsirkin
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.