* [PATCH -next] fw_cfg: Constify struct kobj_type
@ 2024-09-04 1:17 Hongbo Li via
2024-09-18 23:33 ` Gabriel L. Somlo
0 siblings, 1 reply; 2+ messages in thread
From: Hongbo Li via @ 2024-09-04 1:17 UTC (permalink / raw)
To: somlo, mst; +Cc: qemu-devel, lihongbo22
This 'struct kobj_type' is not modified. It is only used in
kobject_init_and_add() which takes a 'const struct kobj_type *ktype'
parameter.
Constifying this structure and moving it to a read-only section,
and this can increase over all security.
```
[Before]
text data bss dec hex filename
5974 1008 96 7078 1ba6 drivers/firmware/qemu_fw_cfg.o
[After]
text data bss dec hex filename
6038 944 96 7078 1ba6 drivers/firmware/qemu_fw_cfg.o
```
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
drivers/firmware/qemu_fw_cfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 5f43dfa22f79..85c525745b31 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -452,7 +452,7 @@ static void fw_cfg_sysfs_release_entry(struct kobject *kobj)
}
/* kobj_type: ties together all properties required to register an entry */
-static struct kobj_type fw_cfg_sysfs_entry_ktype = {
+static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
.default_groups = fw_cfg_sysfs_entry_groups,
.sysfs_ops = &fw_cfg_sysfs_attr_ops,
.release = fw_cfg_sysfs_release_entry,
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] fw_cfg: Constify struct kobj_type
2024-09-04 1:17 [PATCH -next] fw_cfg: Constify struct kobj_type Hongbo Li via
@ 2024-09-18 23:33 ` Gabriel L. Somlo
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel L. Somlo @ 2024-09-18 23:33 UTC (permalink / raw)
To: Hongbo Li; +Cc: mst, qemu-devel
On Wed, Sep 04, 2024 at 09:17:43AM +0800, Hongbo Li wrote:
> This 'struct kobj_type' is not modified. It is only used in
> kobject_init_and_add() which takes a 'const struct kobj_type *ktype'
> parameter.
>
> Constifying this structure and moving it to a read-only section,
> and this can increase over all security.
>
> ```
> [Before]
> text data bss dec hex filename
> 5974 1008 96 7078 1ba6 drivers/firmware/qemu_fw_cfg.o
>
> [After]
> text data bss dec hex filename
> 6038 944 96 7078 1ba6 drivers/firmware/qemu_fw_cfg.o
> ```
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Acked-by: Gabriel L. Somlo <somlo@cmu.edu>
Thanks,
--Gabriel
> ---
> drivers/firmware/qemu_fw_cfg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 5f43dfa22f79..85c525745b31 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -452,7 +452,7 @@ static void fw_cfg_sysfs_release_entry(struct kobject *kobj)
> }
>
> /* kobj_type: ties together all properties required to register an entry */
> -static struct kobj_type fw_cfg_sysfs_entry_ktype = {
> +static const struct kobj_type fw_cfg_sysfs_entry_ktype = {
> .default_groups = fw_cfg_sysfs_entry_groups,
> .sysfs_ops = &fw_cfg_sysfs_attr_ops,
> .release = fw_cfg_sysfs_release_entry,
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-18 23:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 1:17 [PATCH -next] fw_cfg: Constify struct kobj_type Hongbo Li via
2024-09-18 23:33 ` Gabriel L. Somlo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).