EDAC: Constify struct kobj_type
cover EDAC: Constify struct kobj_type
These 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter.
We can constify these struct to move them to text section, and increase over all security.
Hongbo Li (2):
EDAC: Constify struct kobj_type for edac_device_sysfs
EDAC: Constify struct kobj_type for edac_pci_sysfs
drivers/edac/edac_device_sysfs.c | 6 +++--- drivers/edac/edac_pci_sysfs.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 EDAC: Constify struct kobj_type for edac_device_sysfs
These 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter.
Constifying these structure and moving them to a read-only section (from data --> text), and can increase over all security.
``` [Before] text data bss dec hex filename 3913 768 0 4681 1249 drivers/edac/edac_device_sysfs.o [After] text data bss dec hex filename 4105 640 0 4745 1289 drivers/edac/edac_device_sysfs.o ```
--- drivers/edac/edac_device_sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/edac/edac_device_sysfs.c +3 -3
@@ -212,7 +212,7 @@ static void edac_device_ctrl_master_release(struct kobject *kobj) }/* ktype for the main (master) kobject */ -static struct kobj_type ktype_device_ctrl = { +static const struct kobj_type ktype_device_ctrl = { .release = edac_device_ctrl_master_release, .sysfs_ops = &device_ctl_info_ops, .default_groups = device_ctrl_groups,
@@ -397,7 +397,7 @@ static struct attribute *device_instance_attrs[] = {ATTRIBUTE_GROUPS (device_instance);/* The 'ktype' for each edac_dev 'instance' */ -static struct kobj_type ktype_instance_ctrl = { +static const struct kobj_type ktype_instance_ctrl = { .release = edac_device_ctrl_instance_release, .sysfs_ops = &device_instance_ops, .default_groups = device_instance_groups,
@@ -480,7 +480,7 @@ static struct attribute *device_block_attrs[] = {ATTRIBUTE_GROUPS (device_block);/* The 'ktype' for each edac_dev 'block' */ -static struct kobj_type ktype_block_ctrl = { +static const struct kobj_type ktype_block_ctrl = { .release = edac_device_ctrl_block_release, .sysfs_ops = &device_block_ops, .default_groups = device_block_groups,
Signature · 1 line
2.34.1
PATCH 2/2 EDAC: Constify struct kobj_type for edac_pci_sysfs
In reply to Hongbo LiThese 'struct kobj_type' are not modified. They are only used in kobject_init_and_add() which takes a 'const struct kobj_type *ktype' parameter.
Constifying these structure (ktype_pci_instance and ktype_edac_pci_main_kobj)and moving them to a read-only (text section) section, and can increase over all security.
``` [Before] text data bss dec hex filename 4357 856 32 5245 147d drivers/edac/edac_pci_sysfs.o [After] text data bss dec hex filename 4485 760 32 5277 149d drivers/edac/edac_pci_sysfs.o ```
--- drivers/edac/edac_pci_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/edac_pci_sysfs.c +2 -2
@@ -143,7 +143,7 @@ static struct attribute *pci_instance_attrs[] = {ATTRIBUTE_GROUPS (pci_instance);/* the ktype for a pci instance */ -static struct kobj_type ktype_pci_instance = { +static const struct kobj_type ktype_pci_instance = { .release = edac_pci_instance_release, .sysfs_ops = &pci_instance_ops, .default_groups = pci_instance_groups,
@@ -326,7 +326,7 @@ static void edac_pci_release_main_kobj(struct kobject *kobj) }/* ktype struct for the EDAC PCI main kobj */ -static struct kobj_type ktype_edac_pci_main_kobj = { +static const struct kobj_type ktype_edac_pci_main_kobj = { .release = edac_pci_release_main_kobj, .sysfs_ops = &edac_pci_sysfs_ops, .default_groups = edac_pci_groups,
Signature · 1 line
2.34.1